Re: Function not returning



Mike schreef:
//functions.php
<?php
function test($mike) {
if ($mike = "hello"){
>

This is an assignment; it should read:

if ($mike == "hello"){ ...

Tip: Set the fixed value before the variable to prevent mistakes like these in the future:

if ("hello" == $mike){ ...

//test.php
<?php
include("functions.php");
$mike = "hello";
test($mike);
echo $reply;

The test function returns a value, so the proper coding would be:

$reply = test($mike);
echo $reply;


JW
.



Relevant Pages