Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Pages: 1
PHP not working?
Is their any reason why this PHP code will not run in Txp?
The echo test runs fine, but the quote bit won’t run? Is their something about it Txp dislikes?
<txp:php>
function testimonials() {
$quotes = array("One", "Two", "Three", "Four", "Five", "Six");
$title = $quotes[array_rand($quotes)];
echo "Testing PHP works on my site";
}
testimonials();
</txp:php>
~ Cameron
Offline
Re: PHP not working?
You’re not echoing $title. When the <txp:php> block ends, $title is no longer defined (declare it global if that’s what you want).
Offline
Re: PHP not working?
You actually have to call $title
;).
echo "Testing PHP works on my site {$title}";
Edit: Ruud beat me to it :).
Last edited by jm (2008-07-09 13:43:21)
Offline
Pages: 1