Click to See Complete Forum and Search --> : Quick syntax question
Ness_du_Frat
04-13-2006, 05:30 AM
Hi !!!
I'm not sure where I can find this, so I just thought I would ask here...
How can I include a php function in a text, which belongs already to a php function ?
Example is the key, so...
$var='<div class="memo">MÉMOS</div><br /><h2 class="post-title toc-title">Title here</h2>'
Instead of the "title here", I want to insert a php function, and I don't know how I should structure it so I don't get an "unexpected T_string blablabla"
Any clues ?
Thanks a lot !!!!
NogDog
04-13-2006, 05:38 AM
$var = '<div class="memo">MÉMOS</div><br /><h2 class="post-title toc-title">' .
some_function() . '</h2>';
Ness_du_Frat
04-13-2006, 05:43 AM
$var = '<div class="memo">MÉMOS</div><br /><h2 class="post-title toc-title">' .
some_function() . '</h2>';
Thanks for your quick answer, Nog, it was the first thing I tried, and it didn't work, so I decided to post...
I still get the error.
Here is the real stuff :
$block='<div class="memo">MÉMOS</div><br /><h2 class="post-title toc-title">' . create_title("Title here","#cccccc","#ffffff","12",$_SERVER['DOCUMENT_ROOT'].$GLOBALS['theme_uri'].$GLOBALS['__theme']."/journal.ttf").'</h2>';
I get another error message :
Parse error: parse error, unexpected '.', expecting ')' in /var/www/sdb/9/1/psychomoa/dotclear/ecrire/tools/toc/functions.php on line 163
(line 163 is the one with the $block on it)
I guess it's just a matter of brackets or a ; but I can't find it...
Sorry...
Ness_du_Frat
04-13-2006, 05:45 AM
Oh, and I don't know if it changes something, but it's a variable inside a function....
function _getTocTitle (
$conf_show_title,
$block='<div class="memo">MÉMOS</div><br /><h2 class="post-title toc-title">' . create_title("Ton Texte blablabla","#cccccc","#ffffff","12",$_SERVER['DOCUMENT_ROOT'].$GLOBALS['theme_uri'].$GLOBALS['__theme']."/journal.ttf") . '</h2>'
)
NogDog
04-13-2006, 05:57 AM
My guess is that the error is actually somewhere before that line, but for code readability I'd probably rewrite it like this:
$title = create_title("Title here",
"#cccccc",
"#ffffff",
"12",
$_SERVER['DOCUMENT_ROOT'].$GLOBALS['theme_uri'].
$GLOBALS['__theme']."/journal.ttf");
$block = <<<EOD
<div class="memo">MÉMOS</div><br />
<h2 class="post-title toc-title">$title</h2>
EOD;
Ness_du_Frat
04-13-2006, 06:02 AM
oh, it's even worse :(
I've got to go to work, but I'll do some more tries tonight, and I'll post again.
Thanks for your help, Nog !!!
SpectreReturns
04-14-2006, 06:16 PM
Seeing as there's nothing wrong with that code, the problem is probably something of a precedence thing. Try this:
$block = '<div class="memo">MÉMOS</div><br /><h2 class="post-title toc-title">' . create_title("Title here", "#cccccc", "#ffffff", "12", ($_SERVER['DOCUMENT_ROOT'] . $GLOBALS['theme_uri'] . $GLOBALS['__theme'] . "/journal.ttf")) . '</h2>';