S/he's right... technically you're adding HTML to PHP, since the whole thing is sent through the PHP parser.Quote:
Huh?
You can add PHP to html all you want. Just, as you said, put it in PHP tags...
Printable View
S/he's right... technically you're adding HTML to PHP, since the whole thing is sent through the PHP parser.Quote:
Huh?
You can add PHP to html all you want. Just, as you said, put it in PHP tags...
It's a page of text.
1+2 gives the same results as 2+1, unrelated to which is done first or which is being added to the other.
<html></html> --> <html><?php echo "<body>"; ?></html>
No?
It's just an issue of semantics, though, unrelated to the code anyway.
Not necessarily. In fact, I'd say even the <html></html> is technically PHP if it's being sent through the parser; the fact that the PHP parser decides to output this part of the code verbatim is irrelevant.Quote:
<html></html> --> <html><?php echo "<body>"; ?></html>
No?
You have html page. Then you rename that page whatever.php. And that's all PHP code?
Whether or not you want to argue that, it doesn't really hold up in any practical situation. If you're using PHP, you still need to know html, right?
Ah, but what about other file types PHP can send out? CSS, JavaScript, images...they all run through the PHP parser and gives the browser something IT can work with...
I'm with Twey, here. If the file is a PHP file, everything in it is technically PHP.
Only if you want to output HTML. Not necessarily even then, actually, since there are DOM builders and things that allow one to generate an HTML document without knowing HTML, in much the same way that GD allows one to generate a GIF image without knowing the GIF format.Quote:
If you're using PHP, you still need to know html, right?
So... Javascript and CSS are also PHP?
JPGs are as well, if they are served through PHP?
This argument could go on forever, just depending on how you want to look at it.
Is the word "Piñata" Spanish or English when used in English, such as "I just hit a piñata."?
It's Spanish. But it's used in English. It's also an acceptable word in English, without a substitute. So it must be English. But it's Spanish. It's PHP. It's HTML. It's.... a piñata. :p
It's worth knowing that the text is sent through the parser, but only to the extent that you know which portions are actually parsed as PHP and which are not (and what happens to those sections that are). Aside from that, all that matters is that you use the same html as you would have in the first place. Certainly nothing to do with PHP.
On top of that, there's a weird generalization being made by this. PHP code and that-which-is-parsed-as-PHP are two separate things.
There is HTML markup and PHP code on a page, and both are passed through the PHP parser. Each is still its original form, yet they are, yes, passed through the parser. In the same sense, there could be PHP code and HTML markup on a page which is not (either by accident, or perhaps as an example of PHP coding) parsed as PHP at any point. Does that mean that the PHP code is HTML? Sure, it's shown as HTML, but the code itself is still PHP.
If you dump water on a sponge, then it's a sponge... it's intended use. But if you dump water on a rock, that doesn't magically make it a sponge. Sure, it had water dumped on it, so it became a thing-that-has-water-dumped-on-it, but it's still not a sponge...
Considering anything on the page as PHP is ridiculous and vague as things start to lose their meanings. If you were to accidentally parse ASP as PHP, then you're claiming that it is then PHP?
HTML and PHP can exist on the same page, and the difference is when they are interpreted. The PHP parser takes all PHP, and transforms it, but not the HTML, into a final state, which is no longer PHP, but plain text, usually HTML. This is then sent on to the browser, as HTML. The browser then interprets the HTML and displays it.
*Note that in some cases, HTML in this post could/should be expanded to DHTML in general, though it's not too important for the point.
EDIT: In response to your latest post, Twey:
Sure. You can use PHP for different output, but we're talking about a page that has mixed PHP and HTML at the moment. That's irrelevant (and the same argument could occur over PHP generating anything, such as MySQL data).
As for templates/functions in use by PHP to generate html, that may be true, but, again, this IS PHP code, rather than plain HTML on the page. I'm not talking about a page that starts with <?php and ends with ?>, with no breaks to the parsed segment, but a page that has some HTML and some PHP included as well.
EDIT 2: Perspective:
I think the main issue here is how you are looking at the situation.
As the server, it is certainly PHP, and must be parsed as such. The act of not parsing specific segments is part of parsing. So, yes, in a way the HTML is treated as PHP.
However, as the programmer/coder, they are very different things, with the HTML written differently than the PHP.
Perhaps this is partly due to the fact that you're more in touch with how the server actually processes than I am, to a crazy degree (not to say bad... it's useful, and amusing;)), so you're looking at it from this angle.
It's Spanish... the techical term for it is a "loanword." Language definitions are unclear, though... the boundary between a loanword and a native word is as the boundaries between two languages themselves.Quote:
Is the word "Piñata" Spanish or English when used in English, such as "I just hit a piñata."?
It's Spanish. But it's used in English. It's also an acceptable word in English, without a substitute. So it must be English. But it's Spanish. It's PHP. It's HTML. It's.... a piñata. :p
Not really. They're both just binary data, in the end, like languages are just sounds or marks on paper.Quote:
On top of that, there's a weird generalization being made by this. PHP code and that-which-is-parsed-as-PHP are two separate things.
No, it's PHP, since it was interpreted by the PHP parser.Quote:
There is HTML markup and PHP code on a page, and both are passed through the PHP parser. Each is still its original form, yet they are, yes, passed through the parser. In the same sense, there could be PHP code and HTML markup on a page which is not (either by accident, or perhaps as an example of PHP coding) parsed as PHP at any point. Does that mean that the PHP code is HTML? Sure, it's shown as HTML, but the code itself is still PHP.
If it was intended to be used as a sponge, then yes, it's a very poor sponge :)Quote:
If you dump water on a sponge, then it's a sponge... it's intended use. But if you dump water on a rock, that doesn't magically make it a sponge. Sure, it had water dumped on it, so it became a thing-that-has-water-dumped-on-it, but it's still not a sponge...
Invalid PHP, yes.Quote:
Considering anything on the page as PHP is ridiculous and vague as things start to lose their meanings. If you were to accidentally parse ASP as PHP, then you're claiming that it is then PHP?
I'd be inclined to say that the HTML is also transformed -- just into the same HTML that it was in the first place. It's kind of like ROT26 encryption. Movement and transformation are the same thing for electronic and neural data, after all: the electrons of one moment aren't the exact same electrons of the moment before.Quote:
HTML and PHP can exist on the same page, and the difference is when they are interpreted. The PHP parser takes all PHP, and transforms it, but not the HTML, into a final state, which is no longer PHP, but plain text, usually HTML. This is then sent on to the browser, as HTML. The browser then interprets the HTML and displays it.
Then how do you define the chunks that I say are HTML as different from the chunks that I say are PHP? Surely there is a difference, and one that can easily be seen. "HTML parsed as PHP" and "PHP parsed as PHP"? That still means one is PHP and the other is HTML. Perhaps "HTML-like PHP" and "PHP-like PHP"? :p
Heh, ah, you haven't been reading my posts properly :p Since the only way to tell one from the other is by the way they're interpreted, the interpreter defines which is which. The PHP interpreter only sees PHP (thus, it's a PHP interpreter) because it's a machine. Humans are capable of drawing a line between HTML and PHP based on the semantics and patterns of each -- thus, to a human examining the code, there is indeed a difference between the "HTML" portions and the "PHP" portions, and a string such as:is both PHP and HTML, depending on how the examiner is seeing it: if the examiner notes it only as a string that the PHP will output, then it's PHP; if the examiner attempts to work out the final HTML document that the PHP will generate, for example, and takes it in context with the rest of the HTML document, it's HTML.Code:print "<html>";
However, it's silly to attempt to define such things on so ambiguous a measure, so it's wisest to take it at the parser's value (the parser is, after all, the last observer to interpret the code) and say that it's all PHP.