Jump to content

PHP fail.


SpeedCrazy

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

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

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...