Functions with or without paranthesis

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
avantis
Forum Newbie
Posts: 6
Joined: Fri Oct 27, 2006 2:37 am

Functions with or without paranthesis

Post 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
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post 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.
avantis
Forum Newbie
Posts: 6
Joined: Fri Oct 27, 2006 2:37 am

Post 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
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post 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?
avantis
Forum Newbie
Posts: 6
Joined: Fri Oct 27, 2006 2:37 am

Post 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
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post 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'); ?> ?
avantis
Forum Newbie
Posts: 6
Joined: Fri Oct 27, 2006 2:37 am

Post 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.
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

volka wrote:
volka wrote:and where are Db.php, Zend.php and Exception.php located?
really, I do insist on this question.
avantis
Forum Newbie
Posts: 6
Joined: Fri Oct 27, 2006 2:37 am

Post by avantis »

Zend.php is into public_html

Db and Exception are into public_html/Zend
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post 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');
avantis
Forum Newbie
Posts: 6
Joined: Fri Oct 27, 2006 2:37 am

Post 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....
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Re: Functions with or without paranthesis

Post 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>
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post 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.
Post Reply