Re: resolved?? Re: How to transfer value to iframe? [message #183155 is a reply to message #183152] |
Thu, 10 October 2013 23:51 |
Thomas 'PointedEars'
Messages: 701 Registered: October 2010
Karma:
|
Senior Member |
|
|
Thomas 'PointedEars' Lahn wrote:
> Norman Peelman wrote:
>> On 10/10/2013 01:01 PM, richard wrote:
>>> On Wed, 9 Oct 2013 22:32:22 -0400, richard wrote:
>>>> http://mroldies.net/200/audiox.php
>>>>
>>>> First, the sound will work only in firefox.
>>>> So don't go bashing me for that.
>>>
>>>
>>> <?php
>>> $number=$numbers[0];
>>> echo '<iframe id="x1" src="audiox1.php?asong='.$number.'"
>>> name="alpha"></iframe>';
>>> ?>
>>>
>>> At least the first number is now displayed.
>>
>> echo "<iframe id=x1
>> src='audiox1.php?asong=$number&name=$alpha'></iframe>";
>
> The safe syntax is
>
> echo "<iframe id=x1
> src='audiox1.php?asong={$number}&name={$alpha}'></iframe>";
Actually, that is the safe *PHP* syntax (after the line-break is removed).
HTML requires another change:
echo "<iframe id=x1"
. " src='audiox1.php?asong={$number}&name={$alpha}'></iframe>";
AISB, conversion of ”&” to “&” or & can and should be done with
PHP's htmlentities() or htmlspecialchars(), respectively. And “echo” should
not be used like above, but like below:
<iframe id="x1" src="audiox1.php?asong=<?php echo $number;
?>&name=<?php echo htmlspecialchars($alpha); ?>"></iframe>
PHP 5.4 and PHP < 5.4 with corresponding php.ini configuration support
<iframe id="x1" src="audiox1.php?asong=<?= $number ?>&name=<?=
htmlspecialchars($alpha) ?>"></iframe>
and
<iframe id="x1" src="audiox1.php?asong=<%= $number %>&name=<%=
htmlspecialchars($alpha) %>"></iframe>
respectively. Usually you would use a template engine or the MVC pattern:
<iframe id="x1"
src="audiox1.php?asong=<?= $this->number ?>&name=<?=
$this->escape($this->alpha) ?>"></iframe>
This is explained and recommended in the first chapter of the PHP manual.
PointedEars
--
realism: HTML 4.01 Strict
evangelism: XHTML 1.0 Strict
madness: XHTML 1.1 as application/xhtml+xml
-- Bjoern Hoehrmann
|
|
|