标签在 php 5.3.1 中不起作用

发布于 2024-08-25 08:33:26 字数 87 浏览 3 评论 0 原文

我刚刚在我的 Linux 服务器上安装了 php 5.3.1,现在我以前用标签编写的旧作品根本无法工作..

请帮助我.. 我该如何解决这个问题?

I just installed php 5.3.1 in my linux server and now my old work which i used to write with tags is not working at all..

Please help me out..
How can i resolve this??

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

春庭雪 2024-09-01 08:33:26

不建议您使用短标签 ()。您应该使用全长标签 ()。如果您想让您的应用程序可移植,那么另一台服务器上可能不允许使用短的开放标记,因此您的应用程序可能会崩溃。

另一方面,echo 简写 始终可用,无论 php.ini 设置如何,并且不会被弃用。您可以使用它来代替

作为最后的手段,要启用短标记,请通过以下方式之一启用 short_open_tag ini 指令(很可能并非所有方法都适合您):

  • 在 php.ini 中设置指令 short_open_tag = On推荐方式);

  • 在代码中调用 ini_set("short_open_tag", 1);

  • 将以下行添加到您的 .htaccess 文件中:

    php_value Short_open_tag 1


对于默认行为:

------------------------------------------------
php.ini values : short_open_tag
------------------------------------------------

PHP 4, 5_0
 * Default behaviour   : on
 * php.ini-dist        : on
 * php.ini-recommended : on

PHP 5_1, 5_2:
 * Default behaviour   : on
 * php.ini-dist        : on
 * php.ini-recommended : off

PHP 5_3:
 * Default behaviour   : on
 * php.ini-development : off
 * php.ini-production  : off

以及不鼓励短开放标记的原因:

该指令决定 PHP 是否能够识别之间的代码
?> 标记作为 PHP 源,应该这样处理。已经
多年来建议您不要使用短标签“short cut”和
而不是使用完整的 ?> 标记组合。随着广泛使用
XML 和其他语言使用这些标签,服务器可以变得容易
感到困惑并最终在错误的上下文中解析错误的代码。但因为
这个快捷方式已经成为一个功能很长时间了,目前仍然
支持向后兼容性,但我们建议您不要使用它们。


另请注意,此拒绝关于模板的短开放标签的 RFC: http://wiki.php.net/rfc/短标签

It's not recommend you use short tags (<? ?>). You should use the full length tags (<?php ?>). If you want to make your application portable, it's possible that short open tags are not allowed on another server and hence your application will break.

On the other hand, the echo shorthand <?= $var ?> is always available regardless of php.ini settings and will not be deprecated. You can use it instead of <?php echo $var; ?>

As a last resort, to enable short tags, enable the short_open_tag ini directive in one of the following ways (most probably not all of them will work for you):

  • set the directive short_open_tag = On in your php.ini (the recommended way);

  • call ini_set("short_open_tag", 1); in your code;

  • add the following line to your .htaccess file:

    php_value short_open_tag 1


And for the default behaviour:

------------------------------------------------
php.ini values : short_open_tag
------------------------------------------------

PHP 4, 5_0
 * Default behaviour   : on
 * php.ini-dist        : on
 * php.ini-recommended : on

PHP 5_1, 5_2:
 * Default behaviour   : on
 * php.ini-dist        : on
 * php.ini-recommended : off

PHP 5_3:
 * Default behaviour   : on
 * php.ini-development : off
 * php.ini-production  : off

And the reason of discouraging short open tags:

This directive determines whether or not PHP will recognize code between
<? and ?> tags as PHP source which should be processed as such. It's been
recommended for several years that you not use the short tag "short cut" and
instead to use the full <?php and ?> tag combination. With the wide spread use
of XML and use of these tags by other languages, the server can become easily
confused and end up parsing the wrong code in the wrong context. But because
this short cut has been a feature for such a long time, it's currently still
supported for backwards compatibility, but we recommend you don't use them.

Note also this declined RFC about short open tags for templates: http://wiki.php.net/rfc/shortags

暗喜 2024-09-01 08:33:26

看起来您在 php.ini 文件中将 Short_open_tags 设置为“Off”。
尝试将其设置为“On”并重新启动 apache。

Looks like you got short_open_tags set to "Off" in your php.ini file.
Try setting it to "On" and restart apache.

戏蝶舞 2024-09-01 08:33:26

您很可能需要在 PHP 配置文件中打开短标签。在不知道您的配置的情况下,我无法说出您在哪里可以找到它,但您正在寻找 php.ini (很可能在 /etc/php.ini 之类的地方)。

在那里,您需要的设置是 short_open_tags。请参阅此处了解 PHP 的所有核心配置设置。然而,正如其他人提到的,使用短标签可能不是最好的策略。 这里很好地讨论了原因(支持和反对)。

You most likely need to turn on short tags in your PHP configuration file. Without knowing your configuration, I couldn't say where you'd find it, but you're looking for php.ini (most likely somewhere like /etc/php.ini).

In there, the setting you are after is short_open_tags. See here for all core configuration settings for PHP. However as others have mentioned, using short tags might not be the best strategy. Here is a good discussion of the reasons (for and against).

白衬杉格子梦 2024-09-01 08:33:26

也许您的新配置不允许短标签。只需使用 。无论如何,这是更好的做法。

如果您仍然想使用它们,可以使用 short_open_tag 指令。另请记住,如果您禁用了短标签,则这将不起作用。

这样做的主要原因是您可以使用内联 Xml 标记。

maybe your new configuration doesnt alllow short tags. Just use <?php ?>. It is better practise anyway.

If you still want to use them you can short_open_tag directive. Also bear in mind that won't work if you have short tags disabled.

The main reason for this is so you can use inline Xml tags.

ㄟ。诗瑗 2024-09-01 08:33:26

如果您使用 wamp 或 xamp,激活它们非常容易。
只需点击图标->php服务器->设置->允许短标签打开

最好不要使用此功能。例如,xml 使用相同的方式在文档中打开标题。

If you use wamp or xamp, it's really easy to activate them.
Just click on icon->php server->setting->allow short tag open

It's better to not use this functionality. For example xml use the same way to open header in docs.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文