mirror of
https://github.com/smarty-php/smarty.git
synced 2025-11-08 16:21:39 +01:00
84 lines
2.6 KiB
XML
84 lines
2.6 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
|
<!-- $Revision$ -->
|
|
<!-- EN-Revision: 2627 Maintainer: takagi Status: ready -->
|
|
<!-- CREDITS: mat-sh,daichi,joe -->
|
|
<sect1 id="language.function.php">
|
|
<title>{php}</title>
|
|
<para>
|
|
<varname>{php}</varname> タグで、PHP コードを直接テンプレートに埋め込むことができます。
|
|
<link linkend="variable.php.handling"><parameter>$php_handling</parameter></link>
|
|
の設定にかかわらず、これはエスケープされません。
|
|
このタグは上級ユーザのためのものなので通常は必要とされません。
|
|
</para>
|
|
<note>
|
|
<title>テクニカルノート</title>
|
|
<para>
|
|
<varname>{php}</varname> ブロック内の PHP 変数にアクセスするには、PHP の
|
|
<ulink url="&url.php-manual;global"><literal>global</literal></ulink>
|
|
キーワードを使う必要があります。
|
|
</para>
|
|
</note>
|
|
|
|
<example>
|
|
<title>{php} タグ内での PHP コード</title>
|
|
<programlisting>
|
|
<![CDATA[
|
|
{php}
|
|
// PHP スクリプトをテンプレートから直接インクルードします
|
|
include('/path/to/display_weather.php');
|
|
{/php}
|
|
]]>
|
|
</programlisting>
|
|
</example>
|
|
|
|
|
|
<example>
|
|
<title>{php} タグで global を使用して変数を代入する</title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
{* このテンプレートは {php} ブロックを含み、その中で変数 $varX を割り当てます *}
|
|
{php}
|
|
global $foo, $bar;
|
|
if($foo == $bar){
|
|
echo 'This will be sent to browser';
|
|
}
|
|
// 変数を Smarty に割り当てます
|
|
$this->assign('varX','Toffee');
|
|
{/php}
|
|
{* 変数を出力します *}
|
|
<strong>{$varX}</strong> is my fav ice cream :-)
|
|
]]>
|
|
</programlisting>
|
|
</example>
|
|
|
|
<para>
|
|
<link linkend="variable.php.handling"><parameter>$php_handling</parameter></link>、
|
|
<link linkend="language.function.include.php"><varname>{include_php}</varname></link>、
|
|
<link linkend="language.function.include"><varname>{include}</varname></link>、
|
|
<link linkend="language.function.insert"><varname>{insert}</varname></link>
|
|
および
|
|
<link linkend="tips.componentized.templates">コンポーネント化したテンプレート</link>
|
|
も参照してください。
|
|
</para>
|
|
</sect1>
|
|
<!-- Keep this comment at the end of the file
|
|
Local variables:
|
|
mode: sgml
|
|
sgml-omittag:t
|
|
sgml-shorttag:t
|
|
sgml-minimize-attributes:nil
|
|
sgml-always-quote-attributes:t
|
|
sgml-indent-step:1
|
|
sgml-indent-data:t
|
|
indent-tabs-mode:nil
|
|
sgml-parent-document:nil
|
|
sgml-default-dtd-file:"../../../../manual.ced"
|
|
sgml-exposed-tags:nil
|
|
sgml-local-catalogs:nil
|
|
sgml-local-ecat-files:nil
|
|
End:
|
|
vim600: syn=xml fen fdm=syntax fdl=2 si
|
|
vim: et tw=78 syn=sgml
|
|
vi: ts=1 sw=1
|
|
-->
|