How to pass an external $var into an function()
Now, have a look into my page.php, I'll explain my problem inside it.
<?php
$var= "<p>Hello world</p>";
function myfunction1($a){
echo $a;
}
//then
myfunction1($var);//-->OK, return "Hello world!"
//but, the thing is, i don't want to pass any argument into myfunction(),
//so i have to import the external $var into myfuntion2()
function myfunction2(nothing here){
//what's here?
}
myfunction2();//i want to do this
?>
Of course, if i wrap all this inside a CLASS, then myfunction() and $var
turn into method $amp; property (OOP style), these will be so easy to
access! But i don't want to do that!
so, is it possible? Can anyone give me an suggestion? Thanks
No comments:
Post a Comment