用php提供xhtml [英] serving xhtml with php

查看:54
本文介绍了用php提供xhtml的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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


xhtml需要第一行:

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

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


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

<?php

echo''< ;?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?

推荐答案



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


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

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


xhtml需要第一行:

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

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


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

<?php

echo''< ;?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''< ;?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''< ;?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


这篇关于用php提供xhtml的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆