Solved

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

Posted on 2014-03-04
6
1,002 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
  • 3
  • 3
6 Comments
 
LVL 108

Expert Comment

by:Ray Paseur
Comment Utility
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
Comment Utility
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 108

Accepted Solution

by:
Ray Paseur earned 500 total points
Comment Utility
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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

Author Comment

by:kadin
Comment Utility
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 108

Expert Comment

by:Ray Paseur
Comment Utility
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
Comment Utility
Thanks again. I will check it out.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

762 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

Need Help in Real-Time?

Connect with top rated Experts

6 Experts available now in Live!

Get 1:1 Help Now