Forum Moderators: coopster

Message Too Old, No Replies

How to place php code in $var.?

Ex: $var = "This forum is ucwords($great)!"

         

sauce

12:20 am on Jan 19, 2006 (gmt 0)

10+ Year Member



Hi all I'm trying to set html text ina a $var and I can olny get the $vars to print if they are alone... If I tyr to add an array or make them uc I get errors...

Anyone know what I need to add to this code?

$htmltext = "<html>
<head>
<title>ucwords($pagetitle)</title>
</head>
<body>$content</body>
</html>";

Thx

freeflight2

12:26 am on Jan 19, 2006 (gmt 0)

10+ Year Member



$htmltext = "hello ".ucwords($name)."! \n Bye, Bye."

sauce

12:55 am on Jan 19, 2006 (gmt 0)

10+ Year Member



That works!

How about is I add a chunk of code or a file?

$htmltext = "hello ".include("file.php")." \n Bye, Bye."

That piece fails....

freeflight2

1:29 am on Jan 19, 2006 (gmt 0)

10+ Year Member



$htmltext = "hello ".file_get_contents('file.txt')." - and bye."; ;)

sauce

9:04 pm on Jan 19, 2006 (gmt 0)

10+ Year Member



".file_get_contents('file.txt')." includes the file but it doesn't excute the code before outputting. Is there a way to have it run the code in the include file?

mooger35

9:28 pm on Jan 19, 2006 (gmt 0)

10+ Year Member




include("file.php");
$htmltext = "hello ".$var." \n Bye, Bye." ;

inside file.php you define $var