ONJava.com -- The Independent Source for Enterprise Java
oreilly.comSafari Books Online.Conferences.

advertisement

AddThis Social Bookmark Button
Article:
  PHP and Heredocs
Subject:   Why not use php-style instead of perlish (2)?
Date:   2003-04-12 06:55:56
From:   anonymous2
Response to: Why not use php-style instead of perlish ?

Sorry was not detailed enough.


The example should look like this:
$sql="
SELECT *
FROM $table
WHERE field='1' ";


You can have singlequotes in it with no problem.
If you really need Doublequotes you can first try if you can use 'SELECT ... field="2" '; but then Variables are not evaluated. But in many cases you dont need the heredoc, which is essential for PERL, because there you can't use the multiline string like in PHP.


Actually you use a kind of Templatesystem, but it seems a little complicated. I meen you should n't have ANY php in the template but only marker. You can read in the file simply with:
$template_str=join("", file("...path/template.php"); Which also does the trick. And the Designer sees NO php at all.
In your template you can use some marker like {$var} for displaying content which is not php either.


On the other hand, heredoc are useful if you have strings with many quotes and so on.


Daniel


1 to 1 of 1
  1. Why not use php-style instead of perlish (2)?
    2003-04-12 11:34:46  Daniel Smith | [View]

    • Why not use php-style instead of perlish (2)?
      2003-04-15 03:32:34  anonymous2 [View]

      • Why not use php-style instead of perlish (2)?
        2003-04-15 09:48:25  Daniel Smith | [View]

1 to 1 of 1