Link to home
Start Free TrialLog in
Avatar of kadin
kadinFlag for United States of America

asked on

Is it better to echo <<<_END all my html and php code

I use notepad++ as my editor. I like using notepad++ because it is simple and light weight.

notepad++ no longer highlights matching html tags within a php code block. I google for a solution. People at other sites have written about the same problem. It is being recommended that the proper way of coding is to embed the php code within <?php tags ?> at multiple locations throughout the html code. This makes it easier to read the code because the code has color.

I use to do it this way but changed it to putting all my html and php within <?php tags ?> and using echo <<<_END html and php _END; This made the code all one color which is more difficult to read but it was my understanding that the code is more efficient and renders faster using <<<_END.

Is my understanding correct?
If my site had millions of visitors like yahoo or facebook, what should I do? Thanks.
Avatar of Ray Paseur
Ray Paseur
Flag of United States of America image

If my site had millions of visitors like yahoo or facebook, what should I do?
Call a venture capitalist!

The notation you describe is called HEREDOC.  It is a templating tool.  Personally I like it and use it a lot.  But I do not use any color-highlight software.  I think IDE software and NotePad++ are really good things -- I just don't choose them for my work.

You will never be able to find the difference in speed of the choice you made about HEREDOC versus double-quoted strings, versus switching from PHP to HTML and back.  Your web page will render at the same speed, plus or minus a few milliseconds. What will matter to you is the ability to read and understand and modify the PHP + HTML code.  The more back-and-forth you make between PHP and HTML, the more likely you will have a piece of code that contains unwanted dependencies.  It's a computer science thing where we try to remove multiple points of failure, especially in the work environment with several programmers who must share the development process via a set of interacting code repositories.
Avatar of kadin

ASKER

Thanks for your response.

I am having a little trouble understanding unwanted dependencies. There is not several programmers, it's just me. Is unwanted dependencies a real concern?

Are you saying it is more likely to fail because the php interpreter is more likely to fail?

Does going in and out of php cause the server to be called multiple times?
ASKER CERTIFIED SOLUTION
Avatar of Ray Paseur
Ray Paseur
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of kadin

ASKER

If I understand correctly. If my site is not a dot com with a million visitors a day, then don't worry about using HEREDOC to make more efficient and reducing dependencies is likely a non-issue at this point in time for my site.

Thanks for your help.
Thanks for the points and thanks for using EE.  As I look back at this question, I got the feeling that you might benefit from some more foundational information about PHP, so here is a link to my "getting started" article.

All the best, ~Ray
Avatar of kadin

ASKER

Thanks again. I will check it out.