Admin
Registered: 18 years ago
Posts: 10,001
Rating: 353
Say I had a function x that takes an argument
Language: PHP
function x($arg){..whatever
}
Anything you want to do with $arg, do it inside the function. For example, do not clean $arg outside the function, then send it to the function. Clean it inside.
<?phpfunction x ($arg1,$arg2){echo"Hi, my name is ".$arg1." and I specialize in ".$arg2." web application development";}$yourName="Sipho";$yourLang="php";
x($yourName,$yourLang);?>
Makes a lot of sense, limiting the scope of variables also saves us having to come up with different names for variables that hold similar information.