Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

PHP Questions!

Name: Anonymous 2008-06-03 17:12

<?php
if ($expression) {
    ?>
    <strong>This is true.</strong>
    <?php
} else {
    ?>
    <strong>This is false.</strong>
    <?php
}
?>

I am confused by this code.
Can anyone explain to me what happens if $expression is true? false?

Name: Anonymous 2008-06-03 17:15

if($expression) is a shortcut for writing if ($expression == TRUE)
and if (!$expression) a shortcut for if ($expression == FALSE)

Name: Anonymous 2008-06-03 17:48

Use code tags.

Name: Anonymous 2008-06-03 18:06

is anybody going to answer this?

Name: Anonymous 2008-06-03 18:24

>>4
DON'T HELP HIM!

Name: Anonymous 2008-06-03 18:29

>>4
/r/ fuqin angered copypasta, particularly the don't expect answers line.

Name: Anonymous 2008-06-03 18:29

>>5
He has already been helped so for him not to understand it still must mean he is a troll or a bloody idiot.

Name: Anonymous 2008-06-03 18:48

HAHAHAHA
YOU THINK YOURE THOUGH UH ?
I HAVE ONE WORD FOR YOU
  THE FORCED INDENTATION OF THE CODE
GET IT ?
I DONT THINK SO
YOU DONT KNOW ABOUT MY OTHER CAR I GUESS ?
ITS A CDR
AND IS PRONOUNCED ``CUDDER''
OK YOU FUQIN ANGERED AN EXPERT PROGRAMMER
THIS IS /prog/
YOU ARE ALLOWED TO POST HERE ONLY IF YOU HAVE ACHIEVED SATORI
PROGRAMMING IS ALL ABOUT ``ABSTRACT BULLSHITE'' THAT YOU WILL NEVER COMPREHEND
I HAVE READ SICP
IF ITS NOT DONE YOU HAVE TO
TOO BAD RUBY ON RAILS IS SLOW AS FUCK
BBCODE AND ((SCHEME)) ARE THE ULTIMATE LANGUAGES
ALSO
WELCOME TO /prog/
EVERY THREAD WILL BE REPLIED TO
NO EXCEPTIONS

Name: Anonymous 2008-06-03 19:22

>>8
How about the other one?

Name: Anonymous 2008-06-03 19:32

>>9
How about no?

Name: Anonymous 2008-06-03 20:00

This was an example of advanced escaping (according to php).
It's just hard to wrap my head around what exactly the php-engine is doing. For me, there's two ways of looking at this:
(1) PHP reads through the entire file, reassembles the fragmented code, and then interprets it. So the example would reassembled into <?php if ($expression) {} else {} ?>. Afterwards, anything between the appropriate curly braces would be outputted.
(2) PHP reads and evaluates in parts. It reads/evaluates if($expression) and if it's true it then tries to go into the block { but hits the closing tag ?> and pauses, outputting everything until the opening tag <?php and ending with }. But it must read the else statement and the { and then pause again for the closing tag ?>. Normally it would output anything beyond this tag, but it doesn't. Why? How does it know to prevent the HTML code from being output in this case. If this were C, it would be a matter of whether to jump to a block of code or not. But with broken code, it can't know what the block is unless it's read through the entire file as in (1). This is why here we assume it reads through everything sequentially and evaluates only what's necessary. Is that even possible to do?
I guess it stores the HTML code in order. Which means there is another option.
(3) It must make an entire php file out of the combination as follows
if ($expression) { echo "whatever was here in the file" }
else { echo "whatever was here in the file" }
Thats all I can think of.

Name: Anonymous 2008-06-03 21:11

First, Use The Source Luke.

Second, PHP fails and ultimately everything gets converted to a string to be EVALd.

Name: Anonymous 2008-06-03 23:00

>>11
because php is fucking shit and obfusticated

Name: Anonymous 2008-06-04 0:26

PHP is a bleeding fag-infested cunt

Name: Anonymous 2008-06-04 1:39

I think the output is
<strong>This is true.</strong>
<strong>This is false.</strong>
,
and OP is puzzled by this.

lol web programmers

Name: Anonymous 2008-06-04 1:49

>>1
use PerlHP instead.

Name: Anonymous 2008-06-04 6:41

>>15
And you're wrong.

Name: Anonymous 2008-06-04 8:15

And so PHP imitates HTML

Name: Anonymous 2008-06-04 16:10

>>17
Why?

Name: Anonymous 2008-06-04 19:56

>>19
Because you blurted something out that you don't understand
and you're puzzled by this.

Name: Anonymous 2008-06-05 6:33

>>1
Anything wrapped in <?php and ?> is considered by the PHP interpreter to be code. Anything outside that is regarded as data that may be sent back to the web browser.

So, the program you posted is equivalent to:

<?php
if ($expression) {
    print("<strong>This is true.</strong>");
} else {
    print("<strong>This is false.</strong>");
}
?>


(Actually that will differ slightly in the whitespace output, but it's functionally the same when the HTML is interpreted by the browser.)

Name: Anonymous 2008-06-05 14:27

>>21
Anything wrapped in <?php and ?> is considered harmful.

Name: Anonymous 2008-06-05 15:16

>>22
short_tags = true

Name: Anonymous 2008-06-05 15:27

>>23
magic_quotes = true

Name: Anonymous 2008-06-05 15:31

>>23
what

Name: Anonymous 2008-06-05 16:33

>>25
<?
if ($expression) {
    print("<strong>This is true.</strong>");
} else {
    print("<strong>This is false.</strong>");
}
?>

NOT HARMFUL

Name: Anonymous 2008-06-05 18:26

>>23,26
Faggots detected

Name: Anonymous 2008-06-05 20:36

i heard on the streets that php fags call it "echo" or some nonsense like that

Name: Anonymous 2008-06-05 21:30

>>28
They have echo, print, printf, and probably non-function syntaxes for all three.

Name: Anonymous 2008-06-07 3:03

[quote](quote)[/quote]

Name: Anonymous 2008-06-07 4:24

(unquote >>30)

Name: Anonymous 2008-06-07 16:23

addslashes(>>31)

Name: Anonymous 2008-06-07 19:40

>>29
I don't see the point, whatsoever, of echo not being a function. It's the biggest pile of faggotry I have ever whitnessed.

Name: Anonymous 2008-06-07 19:53

>>33
How do I whitnessed faggotry?

Name: Anonymous 2008-06-07 19:59

>>34
.u'i.o'anai mi na jbena lo glico bangu .i mi tavla fo la .lojban.

ki'e .i do bebna malglico .ui

co'o

Name: Anonymous 2008-06-07 20:04

>>35
Go back to bed, Christopher

Name: Anonymous 2008-06-07 20:06

>>35
/jp/ is that way --->

Name: Anonymous 2008-06-07 20:12

>>37

Actually, /jp/ is that way <-----

Name: Anonymous 2008-06-07 20:19

>>38
                           .
                          /|\
                           |
Actually, /jp/ is that way |

Name: Anonymous 2008-06-07 20:35


\
 \
  \
   \
   _\/

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List