0

if var is declare in global so why can't use in function?

16th Aug 2016, 3:46 AM
Ravi Luhar
Ravi Luhar - avatar
5 Respostas
+ 2
yes, you can by defining it as global within function for example: <?php $name = 'Ram'; function getName() { global $name; echo $name; } getName(); ?>
16th Aug 2016, 5:03 PM
Rupali Dadhe
Rupali Dadhe - avatar
0
As Rupali said you have to write global $variablename; before using a global variable.
18th Aug 2016, 11:40 AM
Bekir Uzun
Bekir Uzun - avatar
0
way i am use in global
5th Sep 2016, 7:49 PM
Koishik Ahmed
Koishik Ahmed - avatar
0
think each programing language has its own syntax in c#,java you can but php does not allow that
16th Sep 2016, 11:04 AM
Daniel kabeya kakona
Daniel kabeya kakona - avatar