[英]PHP code showing in browser
我的.php文件中有一些PHP代码,该代码与浏览器中显示的一样。 与之类似,我希望代码在表单提交时执行,但是它在浏览器中显示为纯文本。
<?php
if(isset($_POST['ss-submit']))//submit button name
{
//Describing the Leads object and printing the array
$describe = $connection->describeSObjects(array('Lead'));
print_r($describe);
?>
它下面是可以正确显示的HTML表单。
现在,此.php文件包含在.tpl文件中。
您可以使两个文件保持不同。 如果是聪明人,首先执行php文件,然后处理过程数据,然后借助Assign函数,可以将php的输出分配给tpl文件。
尽可能多地尝试只在php页面上处理数据
<?php
if(isset($_POST['ss-submit']))//submit button name
{
//Describing the Leads object and printing the array
$describe = $connection->describeSObjects(array('Lead'));
$smarty->assign('lead_array',$describe);
?>
将$ smarty替换为您的smarty对象
将lead_array替换为您要访问.tpl文件中的数组的名称
现在在.tpl页面上,您只需编写
{$lead_array|print_r}
确保您在.tpl页面上的表单发布在同一php文件上
它将打印您的数组
这是一个确定的解决方案,请尝试一次,您将获得所需的输出。
在.htaccess文件中
AddType application/x-httpd-php .php .html .tpl
当心这将解析所有tpl文件,就好像它们是php一样。 模板引擎可能更好
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.