Tabs get a parse error.

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
nickman013
Forum Regular
Posts: 764
Joined: Sun Aug 14, 2005 12:02 am
Location: Long Island, New York

Tabs get a parse error.

Post by nickman013 »

Hello,

After searching google, and finding nothing, I decided to ask it here.

Everytime I try to tab my scripts, so it is easier. I get parse errors.
If I remove the tabs It works.

The parse error is
Parse Error wrote: Parse error: parse error, unexpected T_STRING in /home/muot/public_html/index.php on line 13
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

show code.
User avatar
nickman013
Forum Regular
Posts: 764
Joined: Sun Aug 14, 2005 12:02 am
Location: Long Island, New York

Post by nickman013 »

Code: Select all

<?
$page = "welcome.";
include('/home/muot/public_html/pages/includes/add2stat.php');
$folder = 'mainpics'; //No trailing slash 

$images = array(); 

$handle = opendir($folder); 
while ($file = readdir($handle)) 
{ 
$ext = substr($file, -3); 
if ($ext == 'jpg' || $ext == 'gif' || $ext == 'png') 
      { 
$images[] = $file; //Add the file to the array 
} 
} 
closedir($handle); 
shuffle($images); //Jumbly jumbly, shake 'em all about! 
?>
If i remove that tab, it works.

Its wierd, if the code has tabs in it, it doesnt work, if there is no tabs, it works.

Thank You
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

That's just plain weird :?

Can I ask if you're using Macromedia dreamweaver to do your editting? It has issues with sticking invisible characters in the code for some reason (at least it used to)... it used to cause header() issues a lot.
User avatar
nickman013
Forum Regular
Posts: 764
Joined: Sun Aug 14, 2005 12:02 am
Location: Long Island, New York

Post by nickman013 »

I use BBEdit for macintosh.
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

have you tried

1) Switching editors
2) Opening in notepad or whatever mac uses to see if there are any hidden chars
User avatar
nickman013
Forum Regular
Posts: 764
Joined: Sun Aug 14, 2005 12:02 am
Location: Long Island, New York

Post by nickman013 »

Jcart wrote:have you tried

1) Switching editors
2) Opening in notepad or whatever mac uses to see if there are any hidden chars
1. I didnt try switching ediots, becasue this is like the best one made for mac, if you know any other good ones, please let me know.

2. It doesnt add any hidden characters.


Thank You
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

maybe the tab you are inputting isn't actually a tab character?

Code: Select all

echo 'Normal tab: '.implode('',unpack('H*',chr(0x09)))."\n".'Your tab: '.implode(unpack('H*',/* put a tab inside a string here like this
: */ ' '));
functioning normally you should see:

Code: Select all

Normal tab: 09
Your tab: 09
User avatar
nickman013
Forum Regular
Posts: 764
Joined: Sun Aug 14, 2005 12:02 am
Location: Long Island, New York

Post by nickman013 »

Code: Select all

Warning: unpack() [function.unpack]: Type H: outside of string in /home/muot/public_html/test/test.php on line 2

Warning: unpack() [function.unpack]: Type H: outside of string in /home/muot/public_html/test/test.php on line 3
Normal tab: 09 Your tab: 20
I got to find out how to set my tabs to 09.

Thank You
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

did you actually replace the character I had in my example string with a tab from your machine? Because I put a space (20) in it. :)
User avatar
nickman013
Forum Regular
Posts: 764
Joined: Sun Aug 14, 2005 12:02 am
Location: Long Island, New York

Post by nickman013 »

Oh haha, where would I put my tab in?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

read the code.. it may give you a hint. ;)
User avatar
nickman013
Forum Regular
Posts: 764
Joined: Sun Aug 14, 2005 12:02 am
Location: Long Island, New York

Post by nickman013 »

Oh, I didnt understand it the first time I read it.

Code: Select all

Warning: unpack() [function.unpack]: Type H: outside of string in /home/muot/public_html/test/test.php on line 2

Warning: unpack() [function.unpack]: Type H: outside of string in /home/muot/public_html/test/test.php on line 2
Normal tab: 09 Your tab: 09
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

hmmm... weird..
Post Reply