Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/238.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何从smarty模板中的URL访问变量值?_Php_If Statement_Smarty_Query String - Fatal编程技术网

Php 如何从smarty模板中的URL访问变量值?

Php 如何从smarty模板中的URL访问变量值?,php,if-statement,smarty,query-string,Php,If Statement,Smarty,Query String,我在我的网站上使用PHP和smarty。我在地址栏中得到一个URL,我想将URL中的值用在Smarty模板中。那么有可能做到这一点吗?如果是,你能解释一下吗?为了您的理解,我给您的URL如下: http://localhost/eprime/entprm/web/control/modules/enquiries/manage_contact_us.php?contact_id=56&contact_full_name=ZainabJuzerBhavnagarwala&conta

我在我的网站上使用PHP和smarty。我在地址栏中得到一个URL,我想将URL中的值用在Smarty模板中。那么有可能做到这一点吗?如果是,你能解释一下吗?为了您的理解,我给您的URL如下:

http://localhost/eprime/entprm/web/control/modules/enquiries/manage_contact_us.php?contact_id=56&contact_full_name=ZainabJuzerBhavnagarwala&contact_email_id=fatemabhav21@gmail.com&op=view&reply_to_enquiry_suc=1&from_date=11/09/2000&to_date=11/09/2013
假设从上面的URL中,我想访问当前正在显示的smarty模板中变量
contact_full_name
contact_email_id
的值。你能解释一下我是如何做到这一点的吗

实际上,我尝试了以下代码,但它没有输出任何内容

<input type="text" name="contact_full_name" id="contact_full_name" value="{ if $data.contact_full_name!=''} {$data.contact_full_name|capitalize} {else} {$contact_full_name|capitalize} {/if}" class="">

提前感谢。

请看:

看看:

由于Smarty将输出变量的内容(如果存在),如果不存在则什么也不输出,因此您应该:-

<input type="text" name="contact_full_name" id="contact_full_name" value="{$smarty.get.contact_full_name|capitalize}" class="" />

(任何人都可以复制和粘贴LOL)

根据前面的回答:


添加
$smarty->调试\u ctrl='URL'
到php脚本和
&SMARTY_DEBUG
到URL将弹出指定的变量(但不是get和post)

{$SMARTY.get.contact_full_name}
{$smarty.get.contact_email_id}
<input type="text" name="contact_full_name" id="contact_full_name" value="{$smarty.get.contact_full_name|capitalize}" class="" />