Why does my server not like:
(it gives me an error:
Parse error: syntax error, unexpected '}' in /home/uvemympn/public_html/dev/addblog.php on line 16, which line 16 is the last line.)
Yet it's perfectly fine if I take out the comments?
I don't get it. I really don't. I even tried different ways of commenting... # and // both...
if (isset($_POST['url'])) {
#clean URL
print $_POST['url'];
/*
$out = escapeshellarg("addblog-test.pl $url");
print $out;
*/
}
if ($errors){
print "$errors";
}
(it gives me an error:
Parse error: syntax error, unexpected '}' in /home/uvemympn/public_html/dev/addblog.php on line 16, which line 16 is the last line.)
Yet it's perfectly fine if I take out the comments?
if (isset($_POST['url'])) {
#clean URL
print $_POST['url'];
}
if ($errors){
print "$errors";
}I don't get it. I really don't. I even tried different ways of commenting... # and // both...
no subject
Date: 2007-02-14 07:28 pm (UTC)Simple guidelines I would use:
- use // and /* comments not # (stylistic choice on my part
- don't make strings span newlines unless you have to.
- don't embed variables in strings "start $out end" vs "start ".$start." end", it usually works but sometimes it doesn't.
- I like to use echo instead of print, but that's just because I like being reminded I'm doing php and not C
- use proper indentation always, just for shits and giggles
In any case I copy pasted the corrupt code from my browser view of your page and it processed happily on my server.
no subject
Date: 2007-02-14 08:00 pm (UTC)-Embedded variables in strings sometimes doesn't work? In perl, "out=$out" will cause the value of $out to be uh.. embedded, while 'out=$out' will return literally "out=$out". I've been presuming PHP is the same.
-Hm, I believe echo vs. print is just a stylistic choice. I think one might be slightly faster, although I may be mistaken.
-Eh, yeah, I do use proper indentation (4 spaces per tab, tabbing everything inside curly brackets. And I follow (Java?) suggestions of double-tabbing a hard-wrapped line of code. I just didn't bother fixing the spaces when I copied it over to livejournal - despite the fact that it would be just a s/ / /g replacement.
Huh. Wonder if it's a problem with totalchoicehosting's server... Buggers.
no subject
Date: 2007-02-15 03:44 am (UTC)Like I said, arbitrary choice on echo. And I figured the indentation self died... next time copy paste the code into a <pre></pre> block. I do that most of the time for code. I personally like tab-character indentation because then one keypress = 1 unit of operation.