Get Smarty

Donate

Donate Bitcoin Bitcoin
Paypal

Smarty Icon

You may use the Smarty logo according to the trademark notice.

Smarty Template Engine Smarty Template Engine

For sponsorship, advertising, news or other inquiries, contact us at:

Sites Using Smarty

Buy cheap eyeglasses from Cheapglasses123.com and save up to 80%.

Buy prescription glasses from www.australiaglasses.com and save.

Cheap Glasses Now On Sale at GlassesPeople.com. Starts At $7.95.

Where to buy discount wedding dresses and cheap smart dresses free shipping - Weddingdresstrend.com

Brautkleider auf Topwedding.de

Find free files to download on allwhatyouwant.net

Looking For Affordable Wedding Dresses 2015 at Best Prices On TDBridal.com

Shop high quality cheap prom dresses on Dresswe.co.uk

Buy New Arrival Cheap Prom Dresses 2015 at JDBRIDAL Prom Dress Store

Advertisement

Name

assign() 鈥 璧嬪

璇存槑

void聽assign(mixed聽var);
void聽assign(string聽varname,
聽聽聽聽聽聽聽聽聽聽聽聽mixed聽var,
聽聽聽聽聽聽聽聽聽聽聽聽bool聽nocache);

浣犲彲浠ヤ紶閫掗敭鍊煎锛屾垨鑱斿悎鏁扮粍杩涜璧嬪煎埌妯℃澘銆

濡傝缃涓変釜鍙傛暟nocache涓簍rue锛屽垯璇ュ彉閲忎笉杩涜缂撳瓨銆 璇︾粏鍙傝 鍙橀噺缂撳瓨

Note

鍦ㄤ綘浼犻掑璞″埌妯℃澘鏃讹紝璇疯浣忓璞″湪妯℃澘涓娇鐢ㄧ殑鎴愬憳鍙橀噺鍜屾柟娉曞潎鍙负浜嗘樉绀恒傞氳繃瀵硅薄鍦ㄦā鏉夸腑杩涜涓浜涙洿澶嶆潅鐨勫簲鐢ㄩ昏緫鏄緢瀹规槗鐨勪簨鎯咃紝浣嗚繖鏍蜂細鎴愪负杈冨樊鐨勮璁★紝骞朵笖闅句互绠$悊銆傝鍙傝Smarty缃戠珯涓婂叧浜庢渶浣冲疄璺电殑涓婚銆

Example聽14.6.聽assign()


<?php
// 浼犻掗敭鍊煎
$smarty->assign('Name', 'Fred');
$smarty->assign('Address', $address);

// 浼犻掕仈鍚堟暟缁
$smarty->assign(array('city' => 'Lincoln', 'state' => 'Nebraska'));

// 浼犻掓暟缁
$myArray = array('no' => 10, 'label' => 'Peanuts');
$smarty->assign('foo',$myArray);

// 浼犻掍竴琛屾暟鎹簱鐨勮繑鍥炶褰 (濡 adodb)
$sql = 'select id, name, email from contacts where contact ='.$id;
$smarty->assign('contact', $db->getRow($sql));
?>

妯℃澘涓彲浠ョ洿鎺ヤ娇鐢細


{* 鍜宲hp涓鏍凤紝鍙橀噺鍚嶄笉鍖哄垎澶у皬鍐 *}
{$Name}
{$Address}
{$city}
{$state}

{$foo.no}, {$foo.label}
{$contact.id}, {$contact.name},{$contact.email}


鏇村鏁扮粍鐨勪娇鐢ㄦ柟娉曡鍙傝 {foreach}{section}

鍙傝 assignByRef(), getTemplateVars(), clearAssign(), append(){assign}

Comments
No comments for this page.
Post a Comment
All comments are moderated. Support questions are ignored, use the forums instead.
Author:
Email: (not shown)
What is 5 plus 13? (Are you human?)

Advertisement