Forum Moderators: coopster
$my_var = "world";
echo 'hello $my_var';
My next question after that is. Is there any way to globally define a variable and use it in a string, eg.
define("MY_VAR", "world");
echo 'hello {MY_VAR}';
Any help appreciated.
Thanks
Ally
$my_var = "world";
echo 'hello $my_var!';
Becomes:
$my_var = "world";
echo 'hello '.$my_var.'!';
Why do you want to parse PHP within single quotes?
Your define() syntax seems fine, although you are defining constants not variables, and you can't get them from within quotes. Just use a standard variable and then use the 'global' keyword.
now i have duplicated all the tables in the db like so:
table_name
becomes
table_name1, table_name2, table_name3
or
$my_var = 1;
table_name$my_var
I want to do a global find and replace to change any reference to these table name, to save using global $my_var; in every function i want to use a constant.
On top of this alot of the SQL statements are written using single quotes and not doubles so i would need to parse single quotes.
Its a wierd one i know but i really would like not to have to go through every script and manually alter the SQL statements to accomodate what i have done.
Thanks
Ally
[edited by: Scally_Ally at 10:26 am (utc) on Nov. 14, 2007]