passing variable functions from php page to php page

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
kendall
Forum Regular
Posts: 852
Joined: Tue Jul 30, 2002 10:21 am
Location: Trinidad, West Indies
Contact:

passing variable functions from php page to php page

Post 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);
}
User avatar
Takuma
Forum Regular
Posts: 931
Joined: Sun Aug 04, 2002 10:24 am
Location: UK
Contact:

Post by Takuma »

Is this a tip of doing this if it is thanks! :D
User avatar
kendall
Forum Regular
Posts: 852
Joined: Tue Jul 30, 2002 10:21 am
Location: Trinidad, West Indies
Contact:

actually now

Post 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
dusty
Forum Contributor
Posts: 122
Joined: Sun Apr 28, 2002 9:52 pm
Location: Portsmouth, VA

Post by dusty »

$file = file("register.php");
$file = str_replace($Replacement,$Errors,$file);

file() might do the trick.
User avatar
Takuma
Forum Regular
Posts: 931
Joined: Sun Aug 04, 2002 10:24 am
Location: UK
Contact:

Post by Takuma »

Could open file with fopen then read with fread...
Post Reply