Re: note 11784 deleted from echo by ronabop
| From: | Yasuo Ohgaki | Date: | Wed, 21 Mar 2001 07:17:13 +0000 |
| Subject: | Re: note 11784 deleted from echo by ronabop | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-12617@lists.php.net to get a copy of this message | ||
It seems too many notes for echo().
http://www.php.net/manual/en/function.echo.php
My suggestion for PHP Manual regarding to echo() and function()
(Since I posted a bug for script engine and wasted people's time before)
I think it would be nice to rewrite( or add) the line "echo() is not a function"
to "echo() does not return value. Therefore, echo() cannot be a valid
expression". Because this would be the information PHP users need. (I cannot
think of function/construct does not return value now. There may be some, but
I'm sure it rare, isn't it?)
In the manual, it states "echo() is not a function". In reality, it does not
matters for most of cases. For example, one can write
isset($var) ? include('true.php') : require('false.php'); //This is valid
Since include()/require()/include_once()/require_once() returns value (= valid
expression). Programmer can use these language construct just like normal
functions even if these are not a function.
In addition to this, function section in PHP Manual does not clearly states,
function ALWAYS returns a value (NULL for PHP4.0.4pl1) even if programmer does
not return any. So it was unclear for me that echo() does not return value (!=
valid expression)
It also be nice to mention clearly that user defined function always returns a
value in function section(s).
http://www.php.net/manual/en/functions.php
http://www.php.net/manual/en/functions.returning-values.php
It would be valuable info for some programmers, since PHP's function is always
valid expression and can use it as RValue. There is no way for PHP to know it is
a invalid expression, if programmers use user defined function's implicit return
value as RValue by mistake. (Well semantically ok under PHP, but not ok for
programmers) Fortunately, I don't see such code yet, though.
Hope this info helps.
Regards,
--
Yasuo Ohgaki
----- Original Message -----
From: <ronabop@php.net>
Newsgroups: php.notes
Sent: Wednesday, March 21, 2001 2:46 PM
Subject: [PHP-NOTES] note 11784 deleted from echo by ronabop
> echo() is not function, following code is invalid.
>
> ($some_var) ? echo('true'): echo('false');
>
> Print() works
> ($some_var) ? print('true'): print('false');
>
> I thought this is a parser bug at first, but it was not.
>
> --
> PHP Notes Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-notes-unsubscribe@lists.php.net
> For additional commands, e-mail: php-notes-help@lists.php.net
> To contact the list administrators, e-mail: php-list-admin@lists.php.net
>