且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

用php提供xhtml

更新时间:2023-11-27 23:00:16



ab ******** **@yahoo.com 写道:


ab**********@yahoo.com wrote:

是否可以用php提供有效的xhtml?


xhtml需要第一行:

<?xml version =" 1.0" encoding =" iso-8859-1"?>

但php解释了开头<?作为一个php语句。


如果我尝试在PHP中回应这个:

<?php

echo''&lt ;?xml version =" 1.0" encoding =" iso-8859-1"?>'';

?>

xhtml位的结束?被解释为关闭php。

因此:

''; ?>

显示在浏览器中。


有什么方法吗?
Is it possible to serve valid xhtml with php?

xhtml requires the 1st line:
<?xml version="1.0" encoding="iso-8859-1"?>
But php interprets the opening <? as a php statement.

If I try to echo this in PHP:
<?php
echo ''<?xml version="1.0" encoding="iso-8859-1"?>'';
?>
The closing ?of the xhtml bit is interpreted as closing the php.
Thus:
''; ?>
is displayed in the browser.

Any way around this?



这是你的服务器吗?关闭你的php conf中的short_tags。这样你就可以使用<?php not<?


Flamer。

Is it your server? turn off short_tags in your php conf. that way you
can only use <?php not <?

Flamer.



ab ********** @ yahoo.com 写道:

是否可以用php提供有效的xhtml?


xhtml需要第1行:

<?xml version =" 1.0" encoding =" iso-8859-1"?>

但php解释了开头<?作为一个php语句。


如果我尝试在PHP中回应这个:

<?php

echo''&lt ;?xml version =" 1.0" encoding =" iso-8859-1"?>'';

?>

xhtml位的结束?被解释为关闭php。

因此:

''; ?>

显示在浏览器中。


有什么方法吗?
Is it possible to serve valid xhtml with php?

xhtml requires the 1st line:
<?xml version="1.0" encoding="iso-8859-1"?>
But php interprets the opening <? as a php statement.

If I try to echo this in PHP:
<?php
echo ''<?xml version="1.0" encoding="iso-8859-1"?>'';
?>
The closing ?of the xhtml bit is interpreted as closing the php.
Thus:
''; ?>
is displayed in the browser.

Any way around this?



echo''<?xml ...?''。 ''>'';

echo ''<?xml ... ?'' . ''>'';


ab**********@yahoo.com 写道:

是否可以用php提供有效的xhtml?


xhtml需要第一行:

<?xml version =" 1.0" encoding =" iso-8859-1"?>

但php解释了开头<?作为一个php语句。


如果我尝试在PHP中回应这个:

<?php

echo''&lt ;?xml version =" 1.0" encoding =" iso-8859-1"?>'';

?>

xhtml位的结束?被解释为关闭php。

因此:

''; ?>

显示在浏览器中。


可以解决这个问题吗?
Is it possible to serve valid xhtml with php?

xhtml requires the 1st line:
<?xml version="1.0" encoding="iso-8859-1"?>
But php interprets the opening <? as a php statement.

If I try to echo this in PHP:
<?php
echo ''<?xml version="1.0" encoding="iso-8859-1"?>'';
?>
The closing ?of the xhtml bit is interpreted as closing the php.
Thus:
''; ?>
is displayed in the browser.

Any way around this?



也许

<?php

.......

?>

<? xml version =" 1.0" encoding =" iso-8859-1"?>


Louise

Perhaps
<?php
.......
?>
<?xml version="1.0" encoding="iso-8859-1"?>

Louise