Jump to content
Sign in to follow this  
SpeedCrazy

PHP fail.

Recommended Posts

I've actually never even seen heredoc before. I looked it up and it seems to make what you're doing overly complicated. It seems best used for multi line strings.

yes, thats the idea i get, but this is a textbook excersise, i am supposed to learn how the stuff works. What good would it be if i got to large multi line strings and had never used it before? Plus its easier than typing out <?php ?> every time i want php code in my code.

Share this post


Link to post
Share on other sites

Maybe I do not need to learn how to script....... Or code... or any of that. :doh:

Share this post


Link to post
Share on other sites

I've actually never even seen heredoc before. I looked it up and it seems to make what you're doing overly complicated. It seems best used for multi line strings.

In this instance, it is unnecessary and adds an extra level of complexity. Since this is his homework example, it's simply trying to teach a technique... not one that most would use, but still. :P Books tend to focus on one method rather than showing the vast possibilities of writing the same code. If they did that, the book would be a billion pages long, and they would never get past the "Hello World" chapter. :lol: I see heredoc used from time to time in various CMS to spit out template driven items, I think IPB (forum software) did this. The only time I have personally ever used it would be on scripts that send HTML based emails. I have seen a lot of code that fails because they put a space or tab before the final heredoc statement or they forget the semicolon. One reason most people I know avoid it is because it wrecks the code formatting. :P

 

As far as the print vs echo statements... the only reason to use print is because it acts like a function (it isn't one however) and always returns 1. If you need a check, you should use print otherwise you should use echo.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...