Home > Backend Development > PHP Tutorial > php-Is my understanding correct? The reason why $b outputs 1 is because $a defaults to 0?

php-Is my understanding correct? The reason why $b outputs 1 is because $a defaults to 0?

PHP中文网
Release: 2016-08-10 08:49:08
Original
1444 people have browsed it

  php

  • <?phpfunction test (&$b){    $b++;    echo $b.&#39;&#39;;
    }test($a);$a=100;echo $a;
    Copy after login

Reply content:

This code has been changed to better understand the changes in $a:

<?php
function test (&$b){
$b++;
echo $b.&#39;
&#39;;
}
test($a);
echo $a;
$a=100;
echo $a;
Copy after login

Yes, php will initialize a default value for unassigned code. For integers, This value is 0

The initialization value is the same as java.
What should I pay attention to when studying? I think the most important thing is to apply what you have learned, practice more, and write some code that has practical significance. Don’t write too much helloworld-level code, let alone go overboard and create some weird test programs, and pay more attention to real-world problems. .

The above is php - is my understanding correct? The reason why $b outputs 1 is because $a defaults to 0? For more related content, please pay attention to the PHP Chinese website (www.php.cn)!


Related labels:
php
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template