I have some PHP statements as
<?php
$i = 10;
$i = 15;
ec开发者_如何学Pythonho $i;
?>
Now we all are aware of the fact that this will give us "15", what should i do after assignment to the variable $i with value "15", so that we can get output as "10"?
This isn't specific to PHP. When ever you have a list of statements like that that assign values to a variable, the variable will have the value set by the last statement to execute.
You can't. Once a variable has been reassigned its previous value is lost.
You cannot achieve that. But you might do this.
$i[] = 10;
$i[] = 15;
If you assign as above, you will get the following:-
echo $i[0] // will give 10
echo $i[1] // will give 15
you can use array otherwise no way.
精彩评论