PHP echo inside echo
That is some of the ugliest code I have ever seen...
<?php
echo '
<h3>Hello</h3>';
while ($row_indiosct = mysql_fetch_assoc($indiosct))
{
echo '
<div class="indios">
<a href="indio.php?id='.$row_indiosct['id'].'">
<img src="galeria/indios/'. $row_indiosct['foto'].'" alt="'.$row_indiosct['nome'].'" />
<br />'.$row_indiosct['nome'].'</a>
</div>';
}
?>
You could also use the HEREDOC syntax.
How to use echo inside echo
echo '<form method="post" class="product" action="index.php" id="addtocartproduct '. $products->virtuemart_product_id.' ">';
PHP - echo inside an echo
why did you open a <?php
tag again, you are already in echo line?
echo '<td align="left"><a href="'.url('Forum/create_new_post?topic_id='.$post->topic_id.'&forum_id='.$post->forum_id.'').'"><img src="'.SITE_URL.'/lib/skins/flyeuro/images/forums/t_reply.gif"/></a></td>';
and what is SITE_URL
? Is that a variable, did you forget to put $
?
echo prints out the string that you gave as parameter,
echo "foo";
As @hakre mentioned about it, .
is used to concatenate strings.
$var = "foo"."bar"; //foobar
So you can use it in echo line,
$var = "foo"."bar"; //foobar
echo "foo "."bar ".$var // foo bar foobar
And It's not important weather variable defined as a string. It would be a constant variable.
define('SITE_URL', 'localhost:8080/phpvms');
echo "my website URL is ".SITE_URL; //my website URL is localhost:8080/phpvms
Echo inside echo PHP
You can't have PHP tags between PHP tags. Concat the strings instead:
if (is_single()) {
echo '<div><p>html</p>' . do_shortcode( '[contact-form-7 id="1" title="contact form"]' ) . '</div>';
} ?>
echo a command that echoes a quoted string
You can escape the quote characters with \
:
echo "echo\"Hello\"">>script2
Alternatively, use single quotes to ignore special characters inside the string:
echo 'echo"Hello"'>>script2
Related Topics
Check If Current User Is Administrator in Wordpress
How to Insert Multiple Rows Using Prepared Statements
PHP Sessions Login with Remember Me
Scrape Web Site Generated by JavaScript
A Script to Change All Tables and Fields to the Utf-8-Bin Collation in MySQL
How to Convert Date/Time from 24-Hour Format to 12-Hour Am/Pm
Using Comparison Operators in a PHP 'Switch' Statement
Orm/Dao/Datamapper/Activerecord/Tablegateway Differences
Convert Epoch Time to Date PHP
Check If a PHP Cookie Exists and If Not Set Its Value
PHP Method="Post" Stopped Working After I Added This .Htaccess... Why
Is There Open-Source Code for Making 'Link Preview' Text and Icons, Like in Facebook
PHP If Single or Double Equals
Apple Push Notification with Sending Custom Data