*Message Removed*
Edited by Agesilaus (Forum Moderator): Please do not be rude.
*Message Removed*
Edited by Agesilaus (Forum Moderator): Please do not be rude.
Last edited by Agesilaus; 25-12-2007 at 12:59 AM.
If $site_domain and $site_name are already defined in the script then you need to global them into the function:Thats what i got...
All variables are already defined.... but the function wont work... it physically does doesnt change it to anything. Your all saying the same thing, and im saying if you listen, its not working...PHP Code:function replace($string)
{
$pattern = array("{site_domain}", "{site_name}");
$replacement = array("$site_domain", "$site_name");
str_replace($pattern, $replacement, $string);
return $string;
}
PHP Code:function replace($string) {
global $site_domain,$site_name;
....
not always, you could do:
and then doPHP Code:class hi
{
var $sitedomain;
var $site_name;
function replace($string)
{
whatever
}
}
although yours is easier.PHP Code:$function = new hi;
$function->sitedomain = $sitedomain;
$function->site_name = $site_name;
$function->replace("hi");
I didn't think you had to global things in unless they were in a class?
Wow, learn something new every day =]
If you do not global outside variables into the function then the newly defined variables within the function will be returned as null.
Example:
The value of $site within the function would be blank / null.PHP Code:$site='32';
function something($string) {
$string = $site.$string;
}
If you do not global outside variables into the function then the newly defined variables within the function will be returned as null.
Example:
The value of $site within the function would be blank / null.PHP Code:$site='32';
function something($string) {
$string = $site.$string;
}
so if you did global in a class you would be able to use the variables in all of the class' functions?
I believe you need to global it on each function.
Want to hide these adverts? Register an account for free!