Jump to content

Recommended Posts

Ahh didn't pay mind to the whole thing..

 

Take note to your setting of the $c= variable 1 one.. then 3 lines down.. echo test($c); $c by the time it reaches the call to the function is defined as 1, so it is being passed off to the function as 1..

 

function test($a).. $a is contained to the function itself its a static variable you can use within the function itself. Lets try this..

 

 

function monkey($tooth){

if(!is_numeric($tooth)){$output = "Tooth is not Numeric, please enter a number and try again";}
else{

$output = $tooth+20; //taking the numeric value of $tooth and adding 20 to it..

}
return $output;
}

echo monkey(80);
echo "<br />";
echo monkey("abc");

Link to comment
https://forums.phpfreaks.com/topic/241054-quick-query-for-php/#findComment-1238172
Share on other sites

Another thing worth mentioning

 

exit();

 

Not the best way to end your scripts especially if your going to include scripts within scripts via include(), include_once(), require(), require_once().. exit will just halt your scripts rending from the second its executed so any lines there after included via other files or within the same script will not render.

Link to comment
https://forums.phpfreaks.com/topic/241054-quick-query-for-php/#findComment-1238173
Share on other sites

Hope this explanation helps...

// Define function with parameter
function test($thisIsParameter1)
{
// This is the parameter one that u pass to the function,
// dosnt matter what the parameter is called outside the function
// Inside the function it will be $thisIsParameter1.
echo $thisIsParameter1; // will echo out 123
}

$abc = '123';
test($abc) // Use function and pass one parameter $abc to it

Link to comment
https://forums.phpfreaks.com/topic/241054-quick-query-for-php/#findComment-1238250
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.