Echo from function
Posted: Thu Aug 18, 2011 2:25 pm
The name doesn't explain well, but what I'm tying to achieve is probably a smack in the face when i get the answer. What I want is to be able to return a string from a function to be echoed out somewhere else on the page.
Example:
Does anyone think they can help me at all with this? Thanks to any who take this simple task on. 
Example:
Code: Select all
<?php
function myFunction($get) {
$get = $_GET['val'];
if($get!='defined_value') {
$msg = 'You are using the wrong value!';
} else {
$msg = 'You are using the correct value!';
}
}
return $msg;
?>Code: Select all
<div id="response"> <?php echo "This is where I want my function's value returned."; ?> </div>