[Phpmyadmin-devel] PEAR coding standards about require_once

Sebastian Mendel lists at sebastianmendel.de
Sat Jul 8 15:18:48 CEST 2006


Marc Delisle schrieb:
> Sebastian Mendel a écrit :
>> Marc Delisle schrieb:
>>> Hi,
>>>
>>> don't you feel that something is not consistent between
>>>
>>> http://pear.php.net/manual/en/standards.including.php
>>> and
>>> http://pear.php.net/manual/en/standards.control.php
>> no
>>
>>
>>> "require_once" and "if" are both statements, so why does the PEAR 
>>> standard say that you need parenthesis for "if" and not for "require_once"?
>> cause 'if' requires parenthesis for correct syntax
>>
>> and if i would agree you than we had to rite
>>
>> require_once ('file.php');
>>
>> and not
>>
>> require_once('file.php');
>>
>> same for return
>>
>> return ($var);
>>
>> !!! BUT:
>>
>> Note:  Note that since return() is a language construct and not a
>> function, the parentheses surrounding its arguments are only required if
>> the argument contains an expression. It is common to leave them out
>> while returning a variable, and you actually should as PHP has less work
>> to do in this case.
>>
>> Note:  You should never use parentheses around your return variable when
>> returning by reference, as this will not work. You can only return
>> variables by reference, not the result of a statement. If you use return
>> ($a); then you're not returning a variable, but the result of the
>> expression ($a)  (which is, of course, the value of $a).
>>
>>
>> i don't know if "It is common to leave them out while returning a
>> variable, and you actually should as PHP has less work to do in this
>> case." also applies to 'require'
>>
>>
>> so i think you should never write parenthesis where it is not required.
> 
> Too bad the PHP manual does not follow PEAR coding standards:
> http://ca3.php.net/manual/en/function.require-once.php
> 
> require_once("a.php"); // this will include a.php

this is not en example for require_once, it is an example for case
sensitivity in filenames ... ;-)

see:

http://php.net/require
http://php.net/include


-- 
Sebastian




More information about the Developers mailing list