[Info-vax] OS implementation languages

Arne Vajhøj arne at vajhoej.dk
Thu Sep 14 19:59:06 EDT 2023


On 9/14/2023 2:28 PM, Arne Vajhøj wrote:
> On 9/14/2023 6:53 AM, Johnny Billquist wrote:
>> On 2023-09-14 10:39, Bob Eager wrote:
>>> On Thu, 14 Sep 2023 08:39:03 +0000, Bob Eager wrote:
>>>> How about:
>>>>
>>>>   <h2 id="tag<?php>xxxxx</h2>     ?
>>>
>>> Sorry, should be:
>>>
>>>    <h2 id="tag<?php">xxxxx</h2>     ?
>>
>> I would say it's not the quotes that are the most relevant in this. 
>> The fact that you are already inside a tag blocks it from being 
>> interpreted as a tag. Quotes or not.
> 
> No.
> 
> PHP is intended to be used with HTML outside <?php ... ?> and
> in 99.9% of PHP files it is HTML that is outside <?php ... ?>.
> 
> But from a technical perspective then PHP treats what is outside
> <?php ... ?> as literal text.
> 
> No parsing. Does not care what it is.
> 
> And note that even though HTML is sort of the default, then
> PHP can instruct the web server that the content is something else.
> 
> <h1>xxxxxx</h1>
> <?php
> echo "yyyyyy\r\n";
> ?>
> 
> vs:
> 
> <?php
> header("Content-Type: text/plain");
> ?>
> <h1>xxxxxx</h1>
> <?php
> echo "yyyyyy\r\n";
> ?>

In some coding styles it is quite common to have code
inside HTML attributes.

This is just pure PHP code:

$ typ flav1.php
<?php
$opts = array( 'A' => 'This is A', 'B' => 'This is B', 'C' => 'This is C');
echo "<select>\r\n";
foreach($opts as $id => $val) {
    echo "    <option value='$id'>$val</option>\r\n";
}
echo "</select>\r\n";
?>
$ php flav1.php
<select>
     <option value='A'>This is A</option>
     <option value='B'>This is B</option>
     <option value='C'>This is C</option>
</select>

But the same can be done with literal text and smaller PHP fragments:

$ typ flav2.php
<?php
$opts = array( 'A' => 'This is A', 'B' => 'This is B', 'C' => 'This is C');
?>
<select>
<?php
foreach($opts as $id => $val) {
?>
    <option value='<?php echo $id; ?>'><?php echo $val;?></option>
<?php
}
?>
</select>
$ php flav2.php
<select>
    <option value='A'>This is A</option>
    <option value='B'>This is B</option>
    <option value='C'>This is C</option>
</select>

Arne




More information about the Info-vax mailing list