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

kadin
kadin used Ask the Experts™
on
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.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Most Valuable Expert 2011
Top Expert 2016

Commented:
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.

Author

Commented:
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?
Most Valuable Expert 2011
Top Expert 2016
Commented:
Let's take these one at a time.
Does going in and out of php cause the server to be called multiple times?
Yes.  If you have never studied the resulting performance implications, you might want to do so before you raise the question of "does this matter?"  It does not matter at all.  Measure the elapsed time and you can set your mind at ease.
There is not several programmers, it's just me.
If that is the future of your ambition, then there is no reason for unwanted dependencies to matter.  If you ever want to be part of a programming team, then you need to consider how your work will fit in with that team, and how their work will enhance yours.
... the php interpreter is more likely to fail?
No, that will not be one of the things you need to worry about.
JavaScript Best Practices

Save hours in development time and avoid common mistakes by learning the best practices to use for JavaScript.

Author

Commented:
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.
Most Valuable Expert 2011
Top Expert 2016

Commented:
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

Author

Commented:
Thanks again. I will check it out.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial