Page 1 of 1

Functions with or without paranthesis

Posted: Fri Oct 27, 2006 2:41 am
by avantis
My problem is a general PHP problem even it's related to Zend Framework.

I am using Zend Framework for a project i am starting now.

I like this framework but i have a problem on one of servers.

Seems that is not recognized this syntax:

require_once 'Zend/Exception.php';

but

require_once('Zend/Exception.php');

works just fine.

On other server with apparently same php.ini config the syntax without paranthesis is working fine... The files are just fine on server, paths are fine on both servers...

Any idea ?


This is the error i am receiving on logs:


[Thu Oct 26 11:13:59 2006] [error] [client 80.80.80.80] PHP Fatal error: require_once() [<a href='function.require'>function.req
uire</a>]: Failed opening required 'Zend/Exception.php' (include_path='/usr/local/lib/php') in /usr/home/test/public_html/
Zend/Zend.php on line 25

Posted: Fri Oct 27, 2006 3:01 am
by volka
[Thu Oct 26 11:13:59 2006] [error] [client 80.80.80.80] PHP Fatal error: require_once() [<a href='function.require'>function.req
uire</a>]: Failed opening required 'Zend/Exception.php' (include_path='/usr/local/lib/php') in /usr/home/test/public_html/
Zend/Zend.php on line 25
It does recognize the require_once (it even says so). But there is no such file. I really doubt that only require_once('Zend/Exception.php') can fix that.

Posted: Fri Oct 27, 2006 3:55 am
by avantis
Hi,

Thanks for your reply.

I made a simple test with two files of my own and indeed, is working with or without parenthesis.... So, this is not the probleme...

Then, let's tell u what i did for Zend Framework case.

For any require_once without parenthesis, php jumped over this statement - i mean didn't reported any new error, just jumped to next... So i though error is fixed with this simple replace... Problem is i can't replace for all require_once, a lot of code...

So, i am stuck...

This are the errors i get if using Framework without any changes:

[Fri Oct 27 09:52:30 2006] [error] [client 80.80.80.80] PHP Warning: require_once(Zend.php) [<a href='function.require-once'>func
tion.require-once</a>]: failed to open stream: No such file or directory in /usr/home/test/public_html/Zend/Db.php on line
25
[Fri Oct 27 09:52:30 2006] [error] [client 80.80.80.80] PHP Fatal error: require_once() [<a href='function.require'>function.requ
ire</a>]: Failed opening required 'Zend.php' (include_path='/usr/local/lib/php') in /usr/home/test/public_html/Zend/Db.php
on line 25

Posted: Fri Oct 27, 2006 4:13 am
by volka
README.txt wrote:No special installation is required, however the Framework classes
expect that the /library directory is in your include_path.
What does

Code: Select all

<?php echo ini_get('include_path'); ?>
print and where are Db.php, Zend.php and Exception.php located?

Posted: Fri Oct 27, 2006 4:39 am
by avantis
Ok, i used at the beginning of code:

ini_set("include_path", "/usr/local/lib/php; /usr/home/test/public_html; /usr/home/test/public_html/Zend");

But still got same problems:


[Fri Oct 27 10:30:18 2006] [error] [client 80.80.80.80] PHP Warning: require_once(Zend.php) [<a href='function.require-once'>func
tion.require-once</a>]: failed to open stream: No such file or directory in /usr/home/test/public_html/Zend/Db.php on line
25
[Fri Oct 27 10:30:18 2006] [error] [client 80.80.80.80] PHP Fatal error: require_once() [<a href='function.require'>function.requ
ire</a>]: Failed opening required 'Zend.php' (include_path='/usr/local/lib/php; /usr/home/test/public_html; /usr/home/test/public_html/Zend') in /usr/home/test/public_html/Zend/Db.php on line 25

Posted: Fri Oct 27, 2006 4:47 am
by volka
volka wrote:and where are Db.php, Zend.php and Exception.php located?
Is this script running with error_reporting=E_ALL?
Did you check the settings after ini_set with <?php echo ini_get('include_path'); ?> ?

Posted: Fri Oct 27, 2006 4:54 am
by avantis
I checked with <?php echo ini_get('include_path'); ?> and seems to be fine.

Error reporting is set to

error_reporting=E_NONE i guess (high security server), i am taking warning and errors directly from log file.

Posted: Fri Oct 27, 2006 4:55 am
by volka
volka wrote:
volka wrote:and where are Db.php, Zend.php and Exception.php located?
really, I do insist on this question.

Posted: Fri Oct 27, 2006 5:02 am
by avantis
Zend.php is into public_html

Db and Exception are into public_html/Zend

Posted: Fri Oct 27, 2006 5:07 am
by volka
http://de2.php.net/manual/en/ini.core.php#ini.include-path wrote:include_path string

Specifies a list of directories where the require(), include() and fopen_with_path() functions look for files. The format is like the system's PATH environment variable: a list of directories separated with a colon in Unix or semicolon in Windows.
And I wouldn't add spaces even though it's more readable this way.

Code: Select all

ini_set('include_path', ini_get('include_path') . ':/usr/home/test/public_html/Zend');

Posted: Fri Oct 27, 2006 9:21 am
by avantis
Ok, thanks guys....

Both Zend and puclic_html folders must be included (with corect form) into include_path, otherwise will not work.

Now is fine for me....

Re: Functions with or without paranthesis

Posted: Fri Oct 27, 2006 11:57 am
by timvw
<off-topic>
[Thu Oct 26 11:13:59 2006] [error] [client 80.80.80.80] PHP Fatal error: require_once() [<a href='function.require'>function.req
uire</a>]
Should we consider the actual error message as a bug in PHP? require is not a function but a language construct.

</off-topic>

Posted: Fri Oct 27, 2006 5:32 pm
by RobertGonzalez
Are you talking in terms of the displayed text? The functionality for require()/require_once() is correct, according to the docs, in that require()/require_once() produces a fatal error on failure, instead a warning like include()/include_once().

As for whether it is a function or not, there is no argument there. The manual clearly states it is not a function. Unfortunately, the manual lists it in the function index. Go figure.