Click here to Skip to main content
15,920,217 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi. What is the difference between code:

PHP
<?php 
// -- some functions
?>
<div class="text">Some text on page.</div>


PHP
<?php 
// -- some functions
?>
<div class="text">Some text on <?php echo 'page' ?>.</div>


I just want to know, is it ok to open and close php scripts.
Posted

1 solution

The result is the same.

In that case the second is not useful and I would go for the first one for the sake of easiness.

Apart of that it is a good thing to do that if you want to put variables, functions and other results in the HTML text.
 
Share this answer
 
Comments
Lubomur 22-Aug-12 12:21pm    
Large number of such insertions affect the speed of processing scripts?
Joan M 22-Aug-12 14:26pm    
Well, php is a server-side language so the server that is giving you the page must "execute" those insertions and adapt them. I guess the time it takes to make them is not important at all, but yes, I guess that an indecent amount of them can give you a slow result.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900