jaymc Posted June 2, 2008 Share Posted June 2, 2008 I use EOT a lot to save adding slashes when I want to use quotes etc, however, I have ran into an annoying problem check this $number = 3; $cheese = <<<EOT I like to use "quotes" without slashing them, but I can do things like adding $number+1 should come out as 4, but you cant execute code inside of this Am i missing something? EOT; Quote Link to comment https://forums.phpfreaks.com/topic/108454-solved-eot/ Share on other sites More sharing options...
DarkWater Posted June 2, 2008 Share Posted June 2, 2008 Try {$number+1} Quote Link to comment https://forums.phpfreaks.com/topic/108454-solved-eot/#findComment-556050 Share on other sites More sharing options...
jaymc Posted June 2, 2008 Author Share Posted June 2, 2008 Did not work Quote Link to comment https://forums.phpfreaks.com/topic/108454-solved-eot/#findComment-556052 Share on other sites More sharing options...
metrostars Posted June 2, 2008 Share Posted June 2, 2008 You'll have to do the calculations outside EOT then put the variable in, or use "" and . Quote Link to comment https://forums.phpfreaks.com/topic/108454-solved-eot/#findComment-556056 Share on other sites More sharing options...
jaymc Posted June 2, 2008 Author Share Posted June 2, 2008 <? $num = 0; $cheese = <<<EOT hello "mate" "" AND . $num+1} . AND "" ha EOT; echo $cheese; ?> Can you help with syntax? Quote Link to comment https://forums.phpfreaks.com/topic/108454-solved-eot/#findComment-556057 Share on other sites More sharing options...
discomatt Posted June 2, 2008 Share Posted June 2, 2008 No, he's saying you can't do anything requiring evaluation in HEREDOC syntax. You have to use $var = "Some text followed by " . $num+1; More: http://php.net/manual/en/language.types.string.php#language.types.string.syntax.heredoc Quote Link to comment https://forums.phpfreaks.com/topic/108454-solved-eot/#findComment-556060 Share on other sites More sharing options...
jaymc Posted June 2, 2008 Author Share Posted June 2, 2008 Cool Thanks Quote Link to comment https://forums.phpfreaks.com/topic/108454-solved-eot/#findComment-556064 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.