Reply to Re: [Announce] PHPLint 0.3 - PHP source parser and validator

Your name:

Reply:


Posted by Umberto Salsi on 10/01/05 17:37

Janwillem Borleffs <jw@jwscripts.com> wrote:

> You might want to add variable variables and functions support:
>
> $this->$property = @$_REQUEST[$name];
> \_ HERE
> 31: FATAL ERROR: expected property name or method name after `->'

The variable-variables feature is already into my to-do list, but I think
that it will remain there quite a while, together to the variable-function
$f(). The reason is that these programming practices fit well with an
interpreted scripting language, but they are very difficult to check by a
strong-typed language, like PHPLint pretends to parse. The best I can do,
in a future release of the program, is to skip such constructs raising
an error message or a warning just telling that the parser is giving up,
and suggesting to the programmer that there should be a cleaner way.

A final note about the usage of the "@" operator: if $_REQUEST['NAME']
is not set the assignment fail and the variable assigned is not set:

<?
$x = @ $undefinedvar;
echo isset($x)? "set":"not set";
?>

gives:

not set

Moreover, $_REQUEST['NAME'] might be either a string:

http://your.site/your-script.php?NAME=xxx

or an array:

http://your.site/your-script.php?NAME[]=xxx&NAME[]=yyy

If you are expecting a string, you should write something like:

$x = isset( $_REQUEST['NAME'] )? (string) $_REQUEST['NAME'] : "";

or, if you are expecting an array,

$x = isset( $_REQUEST['NAME'] && is_array( $_REQUEST['NAME'] ) )?
$_REQUEST['NAME'] : array();

Regards,
___
/_|_\ Umberto Salsi
\/_\/ www.icosaedro.it

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация