how to include .lib files in php

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
lathangich
Forum Newbie
Posts: 5
Joined: Wed Feb 10, 2010 1:32 pm

how to include .lib files in php

Post by lathangich »

Hi,
I am a newbie to PHP. I am trying to include a header_footer.lib file to my php script.
Currently I am trying with two options:

1. include("./header_footer.lib");

Output :
Parse error: syntax error, unexpected T_STRING in /var/www/cgi-bin/header_footer.lib on line 17

2.include ("/header_footer.lib");

Output :
Warning: include(/header_footer.lib) [function.include]: failed to open stream: No such file or directory in /var/www/cgi-bin/bloomsearch.php on line 9

Warning: include() [function.include]: Failed opening '/header_footer.lib' for inclusion (include_path='.:/usr/share/pear:/usr/share/php') in /var/www/cgi-bin/bloomsearch.php on line 9

Note :The header_footer.lib file contains some sub routines to be used for web pages.Please help me in solving this issue :? Also, how to call those subs in php script.

Thanks in Advance,
Lathangi
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Re: how to include .lib files in php

Post by pickle »

Your first method is correct. Your second is not. The file path sent to include() is a file system path, so your second attempt asks to load a file at the root of your server, not the filesystem.

It looks like you're getting an error on line 17 - seems pretty straightforward.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
lathangich
Forum Newbie
Posts: 5
Joined: Wed Feb 10, 2010 1:32 pm

Re: how to include .lib files in php

Post by lathangich »

pickle wrote:Your first method is correct. Your second is not. The file path sent to include() is a file system path, so your second attempt asks to load a file at the root of your server, not the filesystem.

It looks like you're getting an error on line 17 - seems pretty straightforward.
Thanks for the quick reply. Is that an error from the .lib file? If so, its working fine when included in the perl script. Then why not in php??
User avatar
JNettles
Forum Contributor
Posts: 228
Joined: Mon Oct 05, 2009 4:09 pm

Re: how to include .lib files in php

Post by JNettles »

What's in this .lib file? Whatever is in it is going to be run through the PHP interpreter so it has to be PHP valid.......
lathangich
Forum Newbie
Posts: 5
Joined: Wed Feb 10, 2010 1:32 pm

Re: how to include .lib files in php

Post by lathangich »

JNettles wrote:What's in this .lib file? Whatever is in it is going to be run through the PHP interpreter so it has to be PHP valid.......
The header_footer.lib file contains few sub routines return in perl(to my knowledge)to be used for other web pages.BTW what do you mean by PHP valid? do you mean any script enclosed between <? ?> . If that is so, .lib doesnot contain any php script. how to solve this??
Post Reply