Redirect page problem with IE

D

Duende

On 07 Nov 2005 brucie wrote in alt.html
yes, its a very simple bit of giggly code, easy to read and tell what it
does so i don't bother with multiple lines to improve legibility.

btw, nice to have you back (to pick on)
 
T

Toby Inkster

brucie said:
AFAIK php is insensitive to white space/hard returns

Obviously there are some places where it's important. e.g.

print "Foo";

will work.

print"Foo";

will not.

But overall, PHP is fairly flexible about white space: it certainly
doesn't need any after a statement terminator (semi-colon). More
generally, it doesn't usually need white space after a "punctuation mark".
e.g.

if(1==1){$v=4;$p=9;}else{$v=3;$p=10;}print($v+$p)."\n";
 
D

Duende

AFAIK php is insensitive to white space/hard returns

Obviously there are some places where it's important. e.g.

print "Foo";

will work.

print"Foo";

will not.

But overall, PHP is fairly flexible about white space: it certainly
doesn't need any after a statement terminator (semi-colon). More
generally, it doesn't usually need white space after a "punctuation mark".
e.g.

if(1==1){$v=4;$p=9;}else{$v=3;$p=10;}print($v+$p)."\n";
[/QUOTE]

Thank ye kind sir.
 
J

Jonathan N. Little

Toby said:
brucie wrote:



Well, if you're after the ultra-compact:

<?
if ( isset($_GET['source']) )
exit (highlight_file($_SERVER['SCRIPT_FILENAME'])&&0);
?>

I wonder if anyone (other than brucie) can explain the &&0? :)
I'll take a stab, highlight_file without a 2nd parameter prints rather
than returns a string. The && 0 inverts the boolean output so it exits
with '0' like errorlevel 0 on success and '1' on error.
 
T

Toby Inkster

Jonathan said:
I'll take a stab, highlight_file without a 2nd parameter prints rather
than returns a string. The && 0 inverts the boolean output so it exits
with '0' like errorlevel 0 on success and '1' on error.

You're on the right track. highlight_file() does indeed print out rather
than return a string (though from PHP 4.2, there is an option to return a
string instead). It returns TRUE (assuming success).

So this:

exit(highlight_file(BLAH));

becomes this:

exit(TRUE);

Now, exit() doesn't take a boolean value, but an integer, so it interprets
the TRUE as:

exit(1);

so it exits with an error level of 1. If we add the &&0 we get:

exit(1&&0);

forcing an error level of 0.

Why is the error level important? For non-zero error levels, PHP prints
the error level to the browser, so you end up with a little '1' at the end
of your source code.
 
J

Jonathan N. Little

Toby said:
Jonathan N. Little wrote:




You're on the right track. highlight_file() does indeed print out rather
than return a string (though from PHP 4.2, there is an option to return a
string instead). It returns TRUE (assuming success).

So this:

exit(highlight_file(BLAH));

becomes this:

exit(TRUE);

Now, exit() doesn't take a boolean value, but an integer, so it interprets
the TRUE as:

exit(1);

so it exits with an error level of 1. If we add the &&0 we get:

exit(1&&0);

forcing an error level of 0.

Why is the error level important? For non-zero error levels, PHP prints
the error level to the browser, so you end up with a little '1' at the end
of your source code.

Go to know; you can see it with 'echo print_r $someObject;'

I head is still swimming trying to accommodate PHP's gazillion core
functions Have to spend way too much time scanning the function index to
get anything done... :-(
 
J

Jonathan N. Little

Jonathan N. Little wrote:
Go to know; you can see it with 'echo print_r $someObject;'
^^ That was supposed to be 'good' don't know where the 'od' went!
Better get another cup of coffee.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,802
Messages
2,569,661
Members
45,429
Latest member
FayeWagsta

Latest Threads

Top