Page 1 of 1

how to include .lib files in php

Posted: Wed Feb 10, 2010 1:40 pm
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

Re: how to include .lib files in php

Posted: Wed Feb 10, 2010 2:03 pm
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.

Re: how to include .lib files in php

Posted: Wed Feb 10, 2010 2:07 pm
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??

Re: how to include .lib files in php

Posted: Wed Feb 10, 2010 2:25 pm
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.......

Re: how to include .lib files in php

Posted: Wed Feb 10, 2010 2:37 pm
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??