Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Define statement problem :( 2

Status
Not open for further replies.

cranebill

IS-IT--Management
Jan 4, 2002
1,113
US
I have this define staement per say:

define('TEXT_MAIN', 'testing this $var1 thing');

how do I get $var1 to actually work instead of just showing text?

I have tried escaping to php etc... but it just prints text...

if i do an:
echo $var1;

anywhere outside this define it works...
 
define('TEXT_MAIN', "testing this $var1 thing");

note the ", if the string is in " then only php will parse the variable...

Known is handfull, Unknown is worldfull
 
I recommend that you read up on the differences in PHP between the behavior of doublequoted and singlequoted strings.

This works for me:

Code:
<?php

$var1 = 'foo';

define('TEXT_MAIN', 'testing this ' . $var1 . ' thing');

print TEXT_MAIN;

?>

Want the best answers? Ask the best questions!

TANSTAAFL!!
 
Both examples work in the test example I gave however in the real coding there are things that need to be double quoted which is why the single quotes were used.

sleipnir214's coding actually worked in my running code...

thanks to you both....
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top