Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old May 13th, 2006, 11:59 AM   #1
a thing
Unverified User
 
a thing's Avatar
 
Join Date: Aug 2005
Location: none
Posts: 146
Rep Power: 0 a thing is on a distinguished road
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>
__________________
Warning: My posts may change (dramatically) within the first 15 minutes they're posted.
Got 'Nux?—GNU/Linux and other free software support.
It's GNU/Linux, not just Linux.
a thing is offline   Reply With Quote
Old May 13th, 2006, 12:06 PM   #2
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
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.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote
Old May 13th, 2006, 12:21 PM   #3
a thing
Unverified User
 
a thing's Avatar
 
Join Date: Aug 2005
Location: none
Posts: 146
Rep Power: 0 a thing is on a distinguished road
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.
__________________
Warning: My posts may change (dramatically) within the first 15 minutes they're posted.
Got 'Nux?—GNU/Linux and other free software support.
It's GNU/Linux, not just Linux.
a thing is offline   Reply With Quote
Old May 13th, 2006, 12:33 PM   #4
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road


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]
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote
Old May 15th, 2006, 2:11 PM   #5
demon101
Hobbyist Programmer
 
demon101's Avatar
 
Join Date: Mar 2006
Location: westboro, ohio
Posts: 160
Rep Power: 0 demon101 is an unknown quantity at this point
Send a message via Yahoo to demon101
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 />
__________________
Demon101 Production's

Code Forums
demon101 is offline   Reply With Quote
Old May 15th, 2006, 2:26 PM   #6
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
Nonsense.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote
Old May 15th, 2006, 2:34 PM   #7
demon101
Hobbyist Programmer
 
demon101's Avatar
 
Join Date: Mar 2006
Location: westboro, ohio
Posts: 160
Rep Power: 0 demon101 is an unknown quantity at this point
Send a message via Yahoo to demon101
that is what it shows on the tutorial i have read http://www.w3schools.com/php/php_functions.asp
__________________
Demon101 Production's

Code Forums
demon101 is offline   Reply With Quote
Old May 15th, 2006, 2:48 PM   #8
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
There's nothing wrong with "<br />". There's nothing wrong with "<br/>". I realize you are not misleading people intentionally.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote
Old May 15th, 2006, 11:58 PM   #9
demon101
Hobbyist Programmer
 
demon101's Avatar
 
Join Date: Mar 2006
Location: westboro, ohio
Posts: 160
Rep Power: 0 demon101 is an unknown quantity at this point
Send a message via Yahoo to demon101
so they mean the samethin with or without the space.
__________________
Demon101 Production's

Code Forums
demon101 is offline   Reply With Quote
Old May 16th, 2006, 12:36 AM   #10
a thing
Unverified User
 
a thing's Avatar
 
Join Date: Aug 2005
Location: none
Posts: 146
Rep Power: 0 a thing is on a distinguished road
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]
__________________
Warning: My posts may change (dramatically) within the first 15 minutes they're posted.
Got 'Nux?—GNU/Linux and other free software support.
It's GNU/Linux, not just Linux.
a thing is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 6:57 AM.

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