strip (変数の修飾子) - PHPプロ!マニュアル

Smartyマニュアル

変数の修飾子 - strip

strip

繰り返された空白・改行・タブを、1つの空白または与えられた文字列によって置き換えます。

Note: テンプレートテキストのブロックを対象に取り去りたいなら、 組み込みの {strip} 関数を使用して下さい。

例 5-19. strip

<?php
$smarty
->assign('articleTitle'"Grandmother of\neight makes\t    hole in one.");
$smarty->display('index.tpl');
?>

テンプレート

{$articleTitle}
{$articleTitle|strip}
{$articleTitle|strip:'&nbsp;'}

出力

Grandmother of
eight makes        hole in one.
Grandmother of eight makes hole in one.
Grandmother&nbsp;of&nbsp;eight&nbsp;makes&nbsp;hole&nbsp;in&nbsp;one.

{strip} および truncate も参照してください。



Pick Up Q&A

Q
マジッククォートとmysql_real_escape_string
 このエントリーをはてなブックマークに追加 
A
magic_quotes_gpcでは、SQLインジェクション対処は十分できません。主な理由として、以下が上げられます。 ・magic_quotes_gpcは文字コードを考慮しないで処理するので、Shift_JISを使っている場合、SQLインジェ...

>>続きを読む

SQLインジェクション対策は時と場合で使う関数が変わります。その時にあったものを使いましょう。

▲解説者:岡本(アシアル株式会社 教育コーディネーター兼 システムエンジニア)