Andrew
Andrew

Reputation: 1450

What's that feature of PHP with a section of html/text closed off with start/end functions?

What's that feature of PHP where you have, say a "start" bit of code, then some html or text that would normally send to the browser, then a bit of code to "end" it?

For example,

<? start_something(); ?>

<html>some html</html>

<? end_something(); ?>

Yes, this is a built-in feature of php and I am sure of it, but I cannot remember what it's called.

Upvotes: 0

Views: 60

Answers (6)

SlKelevro
SlKelevro

Reputation: 1

Pretty sure you're asking about output buffering, as mentioned in other answers

Upvotes: 0

sikander
sikander

Reputation: 2286

Take a look at PHP documentation for print()

print <<<END
This uses the "here document" syntax to output
multiple lines with $variable interpolation. Note
that the here document terminator must appear on a
line with just a semicolon no extra whitespace!
END;

Upvotes: 0

gen_Eric
gen_Eric

Reputation: 227280

Output buffering?

<? ob_start(); ?>

<html>some html</html>

<? ob_end_flush(); ?>

Upvotes: 0

John Conde
John Conde

Reputation: 219864

Typically this is how many websites apply a common header and footer to their web pages. By separating them into separate files and including them in each page they can easily maintain a consistent look and feel to their website all while making maintaining it easy since they would only need to update one or two files to change the appearance of the entire site.

Upvotes: 0

Kristian
Kristian

Reputation: 21830

buffer?

ob_start();

//do some code

ob_flush(); //sends current code to browser

//do something else

ob_end_flush(); //or ob_end_clean()

Upvotes: 4

Related Questions