Page 1 of 1

passing variable functions from php page to php page

Posted: Mon Sep 16, 2002 2:42 pm
by kendall
my error function reads the file so dat i could have changed a specific error comment to the generate error using a str_replace(). Now that i have to include the file what is my substitute option.

here is an exxample of my error code

$file = "register.php";
if (($First_Name && $Last_Name) == "")
{
$Replacement = "<!--Name Error-->";
$Error = "Please Enter Your Name!";
ErrorForm($Replacement,$Error,&$file);
exit;
}

function ErrorForm($Replacement,$Errors,&$file)
{
$file = include($file);
str_replace($Replacement,$Errors,$file);
}

Posted: Mon Sep 16, 2002 5:06 pm
by Takuma
Is this a tip of doing this if it is thanks! :D

actually now

Posted: Tue Sep 17, 2002 8:22 am
by kendall
Its not.... well not suppose to have been but if you find it works for you....you're welcome. what i was saying is that because i was include() the file instead of fread() i could not do the str_replace(). i ended up having to so some if statements instead. A bit more untidy but got the job done

any suggestions

Posted: Tue Sep 17, 2002 8:42 am
by dusty
$file = file("register.php");
$file = str_replace($Replacement,$Errors,$file);

file() might do the trick.

Posted: Tue Sep 17, 2002 10:59 am
by Takuma
Could open file with fopen then read with fread...