首页 / PHP / PHP代码被注释掉了
PHP代码被注释掉了
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了PHP代码被注释掉了,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含1836字,纯文字阅读大概需要3分钟。
内容图文
我正在使用安装了apache的CentOS 6.4.我有一个名为cmsSearch.php的php文件.在文件的顶部,我有PHP执行正常(查询Sphinx搜索索引).但是,当我在控制台(Chrome)中查看页面时,我尝试在下面的HTML中运行的任何php(尝试运行foreach并使用Sphinx搜索的结果填充表格)都会被注释掉.这是整个cmsSearch.php文件:
<?php
require("sphinxapi.php");
if($_POST['keyword'])
{
$keyword = $_POST['keyword'];
$client = new SphinxClient();
$client->SetMatchMode(SPH_MATCH_ANY);
$result = $client->Query($keyword, "staffDirectoryMember");
if(!$result)
{
print "ERROR: " . $client->GetLastError();
}
else
{
var_dump($result["matches"]);
}
}
?>
<!DOCTYPE html>
<html>
<head>
<title>Sphinx Test</title>
<style>
.container
{
border: solid 1px black;
height: 350px;
width: 700px;
margin: auto;
padding: 5px;
}
.output
{
margin-top:20px;
border: solid 1px red;
height: 200px;
}
</style>
</head>
<body>
<?echo "TEST"; ?>
<div class="container">
<div>
<form method="post" action="cmsSearch.php">
<input type="text" name="keyword">
<input type="submit" value="Search">
</form>
<div class="output">
<? echo "test2"; ?>
<table>
<thead>
<tr>
<th>ID</th>
<th>Weight</th>
<th>ClientId</th>
<th>DomainId</th>
<th>ContentTypeId</th>
</tr>
</thead>
<tbody>
<?
echo "Above for loop";
foreach($result["matches"] as $match)
{
echo "Print from for loop:";
var_dump($match);
?>
<!-- <tr>
<td><?=$match[id]?></td>
<td><?=$match[weight]?></td>
<td><?=$match[attrs][clientid]?></td>
<td><?=$match[attrs][domainid]?></td>
<td><?=$match[attrs][contenttypeid]?></td>
</tr> -->
<?}
echo "After for loop";
?>
</tbody>
</table>
</div>
</div>
</div>
不确定为什么php执行得很好(我可以回显并且var转储工作),但是然后放在HTML中的任何php只显示为注释而不做任何事情.有人有想法吗?
解决方法:
HTML中包含的PHP使用的是short tags,可以在php.ini文件中关闭.看一下这个指令,如果你想使用它,请确保它设置为true:
short_open_tag true
http://www.php.net/manual/en/ini.core.php#ini.short-open-tag
内容总结
以上是互联网集市为您收集整理的PHP代码被注释掉了全部内容,希望文章能够帮你解决PHP代码被注释掉了所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。