• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 373
  • Last Modified:

PHP "explicit" echo feature

HTML code inside a .PHP file gets conveyed to the output stream without the need for echo statements.
This works nicely in while loop contexts (for instance), such that the php code  loop structure envelopes HTML code and no echo is needed.
 <? while ...  {   // begin loop  ?>
    HTML code
 <?    }// end loop  ?>

1. Where is this documented
2. Does this work in the context of functions too  (as opposed to the above being just inline mainline code?

thanks
0
willsherwood
Asked:
willsherwood
2 Solutions
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
>1. Where is this documented
in the docs, "first page", at least almost:
http://www.php.net/manual/en/language.basic-syntax.php


>2. Does this work in the context of functions too
yes
0
 
Beverley PortlockCommented:
Well, you could start here http://uk3.php.net/manual/en/tutorial.firstpage.php or http://uk3.php.net/manual/en/getting-started.php

"Does this work in the context of functions too  (as opposed to the above being just inline mainline code?"

It might well do, but it would be very poor programming practice to have "side-effect" out from a function and I've never tried it in several years of writing PHP. Functions should be completely self contained. The best way to proceed with a function that generates HTML is to pass it back as a string or echo out the HTML using the ECHO statement.

http://uk3.php.net/echo
0
 
willsherwoodAuthor Commented:
thanks
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

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