⊗ppPmScIV 211 of 447 menu

Internal Function Variables in PHP

Variables declared inside a function are not visible outside. Let's look at an example. Suppose we have the following variable:

<?php function func() { $num = 1; } ?>

Let's try to output the variable $num from outside the function:

<?php function func() { $num = 1; } func(); echo $num; // error ?>

Explain what the result of the code execution will be:

<?php function func() { $aaa = '!!!'; } func(); echo $aaa; ?>

Explain what the result of the code execution will be:

<?php function func($aaa) { $aaa = 222; } func(111); echo $aaa; ?>
English
AfrikaansAzərbaycanБългарскиবাংলাБеларускаяČeštinaDanskDeutschΕλληνικάEspañolEestiSuomiFrançaisहिन्दीMagyarՀայերենIndonesiaItaliano日本語ქართულიҚазақ한국어КыргызчаLietuviųLatviešuМакедонскиMelayuမြန်မာNederlandsNorskPolskiPortuguêsRomânăРусскийසිංහලSlovenčinaSlovenščinaShqipСрпскиSrpskiSvenskaKiswahiliТоҷикӣไทยTürkmenTürkçeЎзбекOʻzbekTiếng Việt
We use cookies for website operation, analytics, and personalization. Data processing is carried out in accordance with the Privacy Policy.
accept all customize decline