?
Solved

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

Posted on 2014-03-04
6
Medium Priority
?
1,108 Views
Last Modified: 2014-03-07
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
Comment
Question by:kadin
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
6 Comments
 
LVL 111

Expert Comment

by:Ray Paseur
ID: 39905207
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
 

Author Comment

by:kadin
ID: 39905243
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
 
LVL 111

Accepted Solution

by:
Ray Paseur earned 2000 total points
ID: 39905312
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
Industry Leaders: 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!

 

Author Comment

by:kadin
ID: 39905328
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
 
LVL 111

Expert Comment

by:Ray Paseur
ID: 39906108
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
 

Author Comment

by:kadin
ID: 39914080
Thanks again. I will check it out.
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses how to implement server side field validation and display customized error messages to the client.
There are times when I have encountered the need to decompress a response from a PHP request. This is how it's done, but you must have control of the request and you can set the Accept-Encoding header.
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…

719 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question