Programming Forums

Programming Forums (http://www.programmingforums.org/forumindex.php)
-   PHP (http://www.programmingforums.org/forum29.html)
-   -   autoindention (http://www.programmingforums.org/showthread.php?t=9754)

a thing May 13th, 2006 10:59 AM

autoindention
 
Is there a way I can get PHP to automatically correctly indent something? For example, make
[php]<?php echo("<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>\n");?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>testing PHP</title>
</head>
<body>
<?php
echo("test 1<br/>\n");
echo("test 2\n");
?>
</body>
</html>[/php]

output
:

<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
        <head>
                <title>testing PHP</title>
        </head>
        <body>
                test 1<br/>
                test 2
        </body>
</html>


instead of
:

<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
        <head>
                <title>testing PHP</title>
        </head>
        <body>
                test 1<br/>
test 2
        </body>
</html>


DaWei May 13th, 2006 11:06 AM

PHP is echoing precisely what you told it to. If it did otherwise, you'd probably like it less. Since the PHP isn't in force when you established your pattern, how's it to know? You'd have as much right expecting the renderer or the server to handle it, which is little to none.

a thing May 13th, 2006 11:21 AM

Quote:

Originally Posted by DaWei
PHP isn't in force when you established your pattern, how's it to know?

I am using PHP for my header and footer. I just put what those header and footer functions output so I didn't have to post another PHP file.

DaWei May 13th, 2006 11:33 AM

:confused:

This is what your PHP interpreter works with:
[php]echo("<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>\n");
echo("test 1<br/>\n");
echo("test 2\n");
[/php]

demon101 May 15th, 2006 1:11 PM

:


echo("<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>\n");
echo("test 1<br />\n");
echo("test 2\n");


there is a space between <br/>.

should be this <br />

DaWei May 15th, 2006 1:26 PM

Nonsense.

demon101 May 15th, 2006 1:34 PM

that is what it shows on the tutorial i have read http://www.w3schools.com/php/php_functions.asp

DaWei May 15th, 2006 1:48 PM

There's nothing wrong with "<br />". There's nothing wrong with "<br/>". I realize you are not misleading people intentionally.

demon101 May 15th, 2006 10:58 PM

so they mean the samethin with or without the space.

a thing May 15th, 2006 11:36 PM

Quote:

Originally Posted by demon101
so they mean the samethin with or without the space.

Yes, there's no need for that extra space.

My PHP interpreter starts with:
[php] echo("<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>
<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">
<!--This file was generated by PHP. For the source of the PHP functions used, see common.txt on the top level of the server.-->
<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\">
<head>
<title>$title</title>
<link media=\"all\" rel=\"stylesheet\" type=\"text/css\" href=\"/css/all.css\"/>
<link media=\"screen,projection\" rel=\"stylesheet\" type=\"text/css\" href=\"/css/LightOnDark.css\"/>
</head>
<body>\n");[/php]


All times are GMT -5. The time now is 10:48 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC