php 文件带有 <? ?> XAMPP 中的标签

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5603898/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 21:57:32  来源:igfitidea点击:

php file with <? ?> tags in XAMPP

php

提问by Testadmin

Possible Duplicate:
How to enable PHP short tags ?

可能重复:
如何启用 PHP 短标签?

Hi

你好

I have Xampp version 1.7.3. While browsing a project it shows error. This is because my php code starts with <?....?>so I want to execute my project with both the <? ..... ?>tag and <?php ....?>tag.

我有 Xampp 版本 1.7.3。浏览项目时显示错误。这是因为我的 php 代码以 开头,<?....?>所以我想同时使用<? ..... ?>标签和<?php ....?>标签来执行我的项目 。

Thanks

谢谢

回答by Pascal MARTIN

You are searching for the short_open_tagdirective ;-)

您正在搜索short_open_tag指令 ;-)


To indicate PHP it should accept <? ... ?>as valid PHP tags, you must put this in your php.inifile :


要指示 PHP 应该接受<? ... ?>为有效的 PHP 标签,您必须将其放入您的php.ini文件中:

short_open_tag = On

Instead of what you currently have :

而不是你目前拥有的:

short_open_tag = Off


Notes :


注意事项:

  • You can find out where your php.inifile is using phpinfo().
  • Generally speaking, you should not use short open tags, as those can be disabled (you've just seen that)
  • 您可以找出您的php.ini文件在哪里使用phpinfo()
  • 一般来说,你不应该使用短的开放标签,因为它们可以被禁用(你刚刚看到)

回答by ThiefMaster

Set short_open_tag = onin your php.ini.

short_open_tag = on在你的 php.ini 中设置。

You could also use php_flag short_open_tag onon your .htaccessfile.

您也可以php_flag short_open_tag on在您的.htaccess文件上使用。

However, you should use <?phpas that cannot be disabled!

但是,您应该使用<?php它,因为它不能被禁用!

回答by Dawson

Don't do it man... <?phpis guaranteed valid on any server running PHP. As a trade off for the extra 3 characters, you can omit the closing ?>... see manual for details.

不要这样做人...<?php保证在任何运行 PHP 的服务器上都有效。作为额外的 3 个字符的折衷,您可以省略结束语?>...有关详细信息,请参阅手册。

http://php.net/manual/en/language.basic-syntax.instruction-separation.php

http://php.net/manual/en/language.basic-syntax.instruction-separation.php