Re: casting static property
| From: | Diogo Neves | Date: | Sun, 31 Aug 2008 18:28:56 +0000 |
| Subject: | Re: casting static property | ||
| References: | 1 2 3 4 5 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-279154@lists.php.net to get a copy of this message | ||
Hi again,
There's what you need ( I think )
Simplified version for web:
http://pastebin.com/d2bfcf495
Simplified version for CLI:
http://pastebin.com/d6ab96ed0
On Sun, Aug 31, 2008 at 7:09 PM, Jochem Maas <jochem@iamjochem.com> wrote:
> Diogo Neves schreef:
>>
>> Sorry, i have no webserver... but I can send all code in the email, right?
>>
>
> you can use pastebin.com.
>
> I also recommend you write reproduce/example code like this for
> the CLI so that other people don't have to go throught the hassle
> of running via a webserver (<br /> is not very helpful in terms of
> readability
>
>> <?php
>> define('a', 0);
>> $b = 0;
>>
>> class foo {
>> private $c = 0;
>> private static $e = 0;
>> private static $f = '0';
>> public function techo() {
>> echo ' direct -->' . 0 . '<br />';
>> echo ' a --> ' . a . '<br />';
>> echo ' (string)a --> ' . (string)a . '<br />';
>> global $b;
>> echo ' b --> ' . $b . '<br />';
>> echo ' c --> ' . $this->c . '<br />';
>> $d = 0;
>> echo ' d --> ' . $d . '<br />';
>> echo ' e --> ' . $this->e . '<br />';
>> // OK, static creates a reference, so?
>> echo ' (int)e --> ' . (int)$this->e . '<br />';
>> echo ' (string)e --> ' . (string)$this->e . '<br
>> />';
>> // What? Why?
>> echo ' f --> ' . $this->f . '<br />';
>> // OK, static creates a reference, so?
>> echo ' (int)f --> ' . (int)$this->f . '<br />';
>> echo ' (string)f --> ' . (string)$this->f . '<br
>> />';
>> // What? Why?
>> }
>>
>> public function techo2() {
>> echo ' direct -->', 0, '<br />';
>> echo ' a --> ', a, '<br />';
>> echo ' (string)a --> ', (string)a, '<br />';
>> global $b;
>> echo ' b --> ', $b, '<br />';
>> echo ' c --> ', $this->c, '<br />';
>> $d = 0;
>> echo ' d --> ', $d, '<br />';
>> echo ' e --> ', $this->e, '<br />';
>> // OK, static creates a reference, so?
>> echo ' (int)e --> ', (int)$this->e, '<br />';
>> echo ' (string)e --> ', (string)$this->e, '<br />';
>> // What? Why?
>> echo ' f --> ', $this->f, '<br />';
>> // OK, static creates a reference, so?
>> echo ' (int)f --> ', (int)$this->f, '<br />';
>> echo ' (string)f --> ', (string)$this->f, '<br />';
>> // What? Why?
>> }
>>
>> public function techo3() {
>> global $b;
>> $d = 0;
>>
>> echo ' direct -->', 0, '<br />',
>> ' a --> ', a, '<br />',
>> ' (string)a --> ', (string)a, '<br />',
>> ' b --> ', $b, '<br />',
>> ' c --> ', $this->c, '<br />',
>> ' d --> ', $d, '<br />',
>> ' e --> ', $this->e, '<br />',
>> // OK, static creates a reference, so?
>> ' (int)e --> ', (int)$this->e, '<br />',
>> ' (string)e --> ', (string)$this->e, '<br />',
>> // What? Why?
>> ' f --> ', $this->f, '<br />',
>> // OK, static creates a reference, so?
>> ' (int)f --> ', (int)$this->f, '<br />',
>> ' (string)f --> ', (string)$this->f, '<br />';
>> // What? Why?
>> }
>> }
>>
>> $foo = new foo( );
>>
>> function mytime( ) {
>> $time = microtime( );
>> $time = explode( " ", $time );
>> $time = $time[1] + $time[0];
>> return $time;
>> }
>>
>> $time1 = mytime( );
>> $foo->techo( );
>> $time2 = mytime( );
>> $totaltime = ($time2 - $time1);
>> echo '<br /><br />techo() --> ', $totaltime, '<br
>> /><br /><br />';
>>
>> $time1 = mytime( );
>> $foo->techo2( );
>> $time2 = mytime( );
>> $totaltime = ($time2 - $time1);
>> echo '<br /><br />techo2() --> ', $totaltime, '<br
>> /><br /><br />';
>>
>> $time1 = mytime( );
>> $foo->techo3( );
>> $time2 = mytime( );
>> $totaltime = ($time2 - $time1);
>> echo '<br /><br />techo2() --> ', $totaltime, '<br
>> /><br /><br />';
>> ?>
>>
>> I believe yes
>>
>> On Sun, Aug 31, 2008 at 5:37 PM, Robert Cummings <robert@interjinn.com>
>> wrote:
>>>
>>> On Sun, 2008-08-31 at 17:09 +0200, Jochem Maas wrote:
>>>>
>>>> Diogo Neves schreef:
>>>>>
>>>>> Hi all,
>>>>>
>>>>> Why a static var don't cast as a dynamic one?
>>>>> See file for more info...
>>>>
>>>> attachments get stripped.
>>>> don't cross post to internals, it's bad form.
>>>> try and formulate your questions a bit better
>>>> (it should take you more time to write your post than
>>>> it takes for someone else to figure out what your going on about.).
>
>
>>> Correction, text attachments don't get stripped.
>
> give a man fish. Diogo already succeeded in sending a text attachment
> in a previous post ... I figured I let him work it out for himself ;-)
>
> .... you pedantic **** :-D
>
>>> Cheers,
>>> Rob.
>>> --
>>> http://www.interjinn.com
>>> Application and Templating Framework for PHP
>>>
>>>
>>
>
>
--
Thanks for your attention,
Diogo Neves
Web Developer @ SAPO.pt by PrimeIT.pt