Perfectionist's code
Moderator: General Moderators
Perfectionist's code
Hello all...
Here's the problem: When i include() files, i dont have those included files formatted to be indented the certain amount that would fit the place that they are being put in, so basically im trying to find a way to include a file but put a leader on each line that would consist of a string of "\t"s. Thanks in advance...
Here's the problem: When i include() files, i dont have those included files formatted to be indented the certain amount that would fit the place that they are being put in, so basically im trying to find a way to include a file but put a leader on each line that would consist of a string of "\t"s. Thanks in advance...
Code: Select all
<?php
ob_start();
include('script.php');
$generated_html = ob_get_contents();
ob_end_clean();
echo str_replace("\r\n", "\r\n\t\t\t", $generated_html);
?>its kinda resource intensive if its just for cosmetic purposes though...
Last edited by rehfeld on Wed Dec 01, 2004 5:14 pm, edited 1 time in total.
You don't get what he's saying I don't think... you will never actually see the 2 files together so it doesnt matter:Todd_Z wrote:Obviously its just referencing, but i dont feel like making all those other files having like 14 indentations before the coding...
file.php
Code: Select all
<?php
include("file2.php");
?>file2.php
Code: Select all
<?php
echo "hello";
?>You will never ever see the word echo or the word hello on file.php unless you are useing some php editor that shows the code when you do an include.
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
guess which library has these options? 
indent: no, yes or auto
If set to yes, *library* will indent block-level tags. The default is no. If set to auto *library* will decide whether or not to indent the content of tags such as title, h1-h6, li, td, th, or p depending on whether or not the content includes a block-level element. You are advised to avoid setting indent to yes as this can expose layout bugs in some browsers.
indent-spaces: number
Sets the number of spaces to indent content when indentation is enabled. The default is 2 spaces.
indent-attributes: bool
If set to yes, each attribute will begin on a new line. The default is no.
indent: no, yes or auto
If set to yes, *library* will indent block-level tags. The default is no. If set to auto *library* will decide whether or not to indent the content of tags such as title, h1-h6, li, td, th, or p depending on whether or not the content includes a block-level element. You are advised to avoid setting indent to yes as this can expose layout bugs in some browsers.
indent-spaces: number
Sets the number of spaces to indent content when indentation is enabled. The default is 2 spaces.
indent-attributes: bool
If set to yes, each attribute will begin on a new line. The default is no.
Thanks rehfeld - it worked... much appreciation.
Okay, so there's the code...
Second problem - If i have an include inside of an include, this doesn't work (my guess because of the ob and it already being dealt with) Anyways, is there a solution?
Code: Select all
<?php
function cleanInclude ($filename, $indentation) {
ob_start();
include($filename);
$generated_html = ob_get_contents();
ob_end_clean();
echo str_replace("\n", "\n".$indentation, $generated_html);
}
?>Second problem - If i have an include inside of an include, this doesn't work (my guess because of the ob and it already being dealt with) Anyways, is there a solution?