|
What is more efficient and/or what is better practice. To echo the html or the have many open and close php tags?
Obviously for big areas of html it is sensible to open and close the php tags. What about when dealing with something like generating XML...
Started by Mark on
, 9 posts
by 9 people.
Answer Snippets (Read the full thread at stackoverflow):
But an echo of a big string is hard to read and more <?php echo $this->that; ?> tell a story_double_quote'),....
Example:
echo <<.
Check it out please.
PHP solves this problem by what is known as heredocs .
|
|
How to access PHP varibles in Javascript or Jquery? Do I have to write
<?php echo $variable1 ?> <?php echo $variable2 ?> <?php echo $variable3 ?> ... <?php echo $variablen ?>
I know I can store some variables in cookies,and access...
Started by Steven on
, 6 posts
by 6 people.
Answer Snippets (Read the full thread at stackoverflow):
You write alert('<?php echo($phpvariable); ?>');
There are sure other ways="text/javascript"> var simple = '<?php echo $simple; ?>'; var complex = <?php echo json' => array....
Basically, yes.
|
|
So I have a script that I debug with a bunch of echo statements. This is run every 3 minutes on my server by cron, and I sometimes leave the echo statements in there. They're not going to a browser, they're just going... anywhere?
This is a vague question...
Started by Alex Mcp on
, 3 posts
by 3 people.
Answer Snippets (Read the full thread at stackoverflow):
You can write the output of your script to a file via:
php myscript.php > /var the output elsewhere on the....
Is that if you leave some echo statements in a PHP script and set it as a cron job, then you will start of the crontask).
|
Ask your Facebook Friends
|
Hi i work a lot in mixed html and php and most time i just want solid html with a fet php variables in it so my code look like this
<tr><td> <input type="hidden" name="type" value="<?php echo $var; ?>" ></td></tr>
wich...
Started by matthy on
, 6 posts
by 6 people.
Answer Snippets (Read the full thread at stackoverflow):
Personally I don't mind mixing HTML and PHP like so
<a href="<?php echo php configuration.....
In their internal implementation:
<?= $var1, $var2 ?> <?php echo $var1, $var2 ?> information on why.
|
|
Hi, I need to echo an include from my php function. I have tried the below but neither work? Does php support this within a function?
echo "<?php include ('http://www.mysite.com/script.php'); ?>"; echo "include (\"http://www.mysite.com/script.php...
Started by Elliott on
, 6 posts
by 6 people.
Answer Snippets (Read the full thread at stackoverflow):
If you want to include something, just do it
include ('http://www.mysite.com/script.php');
You don't need to print out PHP source code, when you're writing PHP....
Echo prints something to the output buffer - it's not parsed by PHP.
|
|
The PHP short tag <?= $var ?> has been deprecated for a while. Almost all PHP frameworks use the long form <?php echo $var ?> (e.g., symphony , Yii , Kohana ) Smarty is a famous PHP template engine which supports a shorter form {$var} Template...
Started by Wernight on
, 9 posts
by 9 people.
Answer Snippets (Read the full thread at stackoverflow):
Foreach ($k as $v) { ?> <option value="<?php echo htmlentities($v['value']); ?>"><?php echo htmlentities($v['label']); ?></option> <?php } ?> </select>
NowThere are some reasons....
|
|
I'm almost sure the answer to this is "None at all!" but I'll ask anyway. If you have a conditional statement in PHP which echos a line of html, is there any difference performance-wise between these 2 examples:
<?php if ($output) { ?> <h2>...
Started by ewengcameron on
, 11 posts
by 11 people.
Answer Snippets (Read the full thread at stackoverflow):
Consider
<span> <?php echo $myMessage; ?> </span>
and
<?php echo "<span>\n"; echo $myMessage; echo "</span>....
And no string concatenation)
The answer literally is "None at all" .
|
|
Are they equal in safeness? I was informed that using
<?=$function_here?>
was less safe, and that it slows down page load. So I am now strictly biased to using echo.
I just wanted to know the advantages/disadvantages, or are they pretty much the...
Started by Joey on
, 3 posts
by 3 people.
Answer Snippets (Read the full thread at stackoverflow):
Actually, in the php.ini-production file provided with PHP 5.3.0, they are disabled if they are not enabled.....
Questions/200640/are-php-short-tags-acceptable-to-use http://stackoverflow.com/questions/234241/how-are-echo directive).
|
|
I want to conditionally output HTML to generate a page, so what's the easiest way to echo multiline snippets of HTML in PHP 4+? Would I need to use a template framework like SmartyPants?
echo '<html>' + '\n'; // I'm sure there's a better way! echo...
Started by Jeremy Rudd on
, 9 posts
by 9 people.
Answer Snippets (Read the full thread at stackoverflow):
; ?> </body> </html>
Note: you may need to use <?php echo $var; ?> instead of <) ie:
<?php ob_start(); echo('hello world'); $php_output = ob_get_contents(); ob_end_clean(); ?> <h1> ....
|
|
I recently looked at my source code and it was a real mess.
my php source:
echo '<h1>Rar<h1>'; echo '<span>Rar</span>'; echo '<p>Rar</p>';
and when I view the browser source for the page rendered:
<h1>Rar</...
Started by Ygam on
, 6 posts
by 6 people.
Answer Snippets (Read the full thread at stackoverflow):
This would append the OS specific newline values with echo like this:
echo 'one', $foo, PHP_EOL, 'two', $bar, PHP_EOL;
so there is no need; &....
Method and replace all echo statements with echo PHP_EOL, .
|