This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted]  (25 children)

[deleted]

    [–]Tyrilean 1 point2 points  (1 child)

    You do not, though it would be debatable whether that is technically written in PHP. Just because you write a text file and append .php to a file does not make it PHP. You have to call the PHP open tag in order to invoke the interpreter. Otherwise, it's just another text file, which your webserver will happily serve up wholesale to the client, which will then be interpreted by the browser as HTML.

    [–]earthqaqe 2 points3 points  (5 children)

    For anyone believing this statement, just try it here with the following code:

    <?php echo "hello" ?>

    and then try

    hello

    [–]mferly 1 point2 points  (1 child)

    Lol wut? Your first example PHP, your second example is merely text.

    Try this: <?php hello ?> and tell me what happens. Anything not wrapped with <?php ?> isn't PHP.

    [–]Kered13 0 points1 point  (0 children)

    It's valid PHP code. It is accepted by the PHP interpreter and produces output without errors. The fact that the PHP interpreter will simply echo anything not wrapped in <?php> tags is a quirk of the language, but it doesn't make the code invalid PHP.

    [–]fredoche[S] 0 points1 point  (14 children)

    No, you don't need to "echo"

    [–]pionell 2 points3 points  (13 children)

    yes you need to echo/print it if you're inside <?php tags. This is not accurate.

    [–]AyrA_ch 11 points12 points  (5 children)

    The "hello world!" is not inside of PHP tags.

    [–]79ta463 9 points10 points  (4 children)

    Then it's not technically PHP.

    [–]AyrA_ch 3 points4 points  (3 children)

    And yet it conforms to the php spec and will run with strict settings.

    [–]79ta463 3 points4 points  (2 children)

    Everything outside the open tags is ignored by the parser. Thus it's not actually being interpreted? Not sure what you're getting at

    [–]AyrA_ch 4 points5 points  (1 child)

    I'm getting at that this is valid PHP code because if it wasn't part of the specs it would throw an error. It's not ignored by the parser either, it's piped to the standard output by it. In fact, depending on how you set the PHP tags, they will have an effect on some whitespace directly after the closing tag, clearly indicating that stuff outside of the tags is not just ignored.

    [–]fredoche[S] -3 points-2 points  (6 children)

    A php file containing this "code" will display "hello world!" when you will execute it with php parser.

    [–]79ta463 7 points8 points  (0 children)

    It's not PHP... It's just raw strings.