Re: could PHP benefit from strict typing?
| From: | Justin French | Date: | Mon, 16 Sep 2002 01:40:04 +0000 |
| Subject: | Re: could PHP benefit from strict typing? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-116482@lists.php.net to get a copy of this message | ||
Although not answering the full question;
$myint = 5;
$myint = 5 + 5;
$mystr = 'single quotes for stuff without a variable';
$mystr = "double quotes for things with have a $variable";
$mystr = "better again to use {$variable} or {$_GET['variable']}";
Basically, double quote implies that PHP should look for, and substitute a
$variable in the string, where as single quote mean it's just a string.
I imagine if you followed these rules across a large site with huge hits,
yes, you'd see some sort of performance gain.
Justin French
on 16/09/02 10:33 AM, Rob (dillybar1@black-hole.com) wrote:
> i was just thinking the other day about loosely typed scripting languages,
> like PHP, and pondering
> how much extra work the parser must go through to track, test and convert data
> types.
>
> this is one of the key appeals of PHP, so i'm not suggesting PHP should be
> strictly typed, i'd hate
> that too. But if there were an optional method of using strict typing in
> cases where performance is
> an issue, could it create a significant performance improvement?
>
> i was thinking something along the lines of:
>
> string $mystring = 'hello world';
> int $myint = 5;
> $myint = 70; // ok
> $myint = 'blah blah'; // error
> int $somevar = $myint + $mystring; // error
> bool $mybool = 'some string'; // error
> $thisvar = 'any type'; // regular, variant typed variable
>
> it's quite possible i have no clue and this wouldnt help one bit, just a
> thought
>
>
> -Rob
>