Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1134
  • Last Modified:

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.
0
kadin
Asked:
kadin
  • 3
  • 3
1 Solution
 
Ray PaseurCommented:
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.
0
 
kadinAuthor 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?
0
 
Ray PaseurCommented:
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.
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
kadinAuthor 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.
0
 
Ray PaseurCommented:
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
0
 
kadinAuthor Commented:
Thanks again. I will check it out.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now