Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB
ÈÈÃűêÇ©£º c c# c++ asp asp.net linux php jsp java vb Python Ruby mysql sql access Sqlite sqlserver delphi javascript Oracle ajax wap mssql html css flash flex dreamweaver xml
 ×îÐÂÎÄÕ : php

PHP smarty foreachÓ÷¨£¡

ÊôÐÔÃû³Æ£ºfrom£¬item,key,name
×¢Ò⣺
1,fromºÍitemÊDZØÒªÊôÐÔ
2,{foreach}Ñ­»·µÄname¿ÉÒÔÊÇÈκÎ×Öĸ£¬Êý×飬Ï»®ÏßµÄ×éºÏ£¬²Î¿¼PHP±äÁ¿¡£
3,{foreach}Ñ­»·¿ÉÒÔǶÌ×£¬Ç¶Ì×µÄ{foreach}µÄÃû³ÆÓ¦µ±»¥²»Ïàͬ¡£
ÎļþÒ»£ºindex.tpl
<b>ÏÂÃæµÄÊý¾Ý·Ö±ðÊÇ£º</b>
<ul>
{foreach from=$myArray1 key=k item=foo}
<li>{$k+1}:{$foo}</li>
{/foreach}
</ul>
<ul>
{foreach from=$myArray2 key=k item=v}
<li>{$k}: {$v}</li>
{/foreach}
</ul>
<ul>
{foreach from=$myArray3 key=myId item=i}
<li><a href="item.php?id={$myId}" mce_href="item.php?id={$myId}">{$i.no}: {$i.label}</li>
{/foreach}
</ul>

Îļþ¶þ£ºindex.php
<?php
require 'Smarty.class.php';
$smarty = new Smarty;
$smarty->assign('myArray1', array("ÐÇÆÚÒ»", "ÐÇÆÚ¶þ", "ÐÇÆÚÈý"));
$smarty->assign('myArray2', array("Öйú" => 'China', "Ó¢¹ú" => 'England', "¶í¹ú" = ......

php evalº¯ÊýÓ÷¨ PHPÖÐeval()º¯ÊýС¼¼ÇÉ

php evalº¯ÊýÓ÷¨----PHPÖÐeval()º¯ÊýС¼¼ÇÉ
eval
½«Öµ´úÈë×Ö·û´®Ö®ÖС£
Óï·¨: void eval(string code_str);
´«»ØÖµ: ÎÞ
º¯Ê½ÖÖÀà: Êý¾Ý´¦Àí
ÄÚÈÝ˵Ã÷
±¾º¯Ê½¿É½«×Ö·û´®Ö®ÖеıäÁ¿Öµ´úÈ룬ͨ³£ÓÃÔÚ´¦ÀíÊý¾Ý¿âµÄÊý¾ÝÉÏ¡£²ÎÊý code_str ΪÓû´¦ÀíµÄ×Ö·û´®¡£ÖµµÃ×¢ÒâµÄÊÇ´ý´¦ÀíµÄ×Ö·û´®Òª·ûºÏ PHP µÄ×Ö·û´®¸ñʽ£¬Í¬Ê±ÔÚ½áβ´¦ÒªÓзֺš£Ê¹Óñ¾º¯Ê½´¦ÀíºóµÄ×Ö·û´®»áÑØÐøµ½ PHP ³ÌÐò½áÊø¡£
ʹÓ÷¶Àý
<?php
$string = '±­×Ó';
$name = '¿§·È';
$str = 'Õâ¸ö $string ÖÐ×°ÓÐ $name.<br>';
echo $str;
eval( "\$str = \"$str\";" );
echo $str;
?>
±¾ÀýµÄ´«»ØֵΪ
Õâ¸ö $string ÖÐ×°ÓÐ $name.
Õâ¸ö ±­×Ó ÖÐ×°ÓÐ ¿§·È.
///////////////////////////////////////////
PHPÖÐeval()º¯ÊýС¼¼ÇÉ
Ò»Ö±ÒÔÀ´¸Ð¾õeval()º¯ÊýËƺõ²»ÄÜ×ö¸³ÖµÔËË㣿ÍøÉÏÓÐЩÎÄÕÂÒ²ÕâÑù˵¹ý£¡
±ÈÈçeval("$a=55;");Õâ¸öʽ×ӾͻáÌáʾ´íÎó£¡
ÊDz»ÊÇeval()º¯ÊýÖ´ÐеĴúÂë²»ÄÜ×ö¸³ÖµÔËËãÁËÄØ£¬Æäʵ²»ÊÇ¡£ÕâÊÇÒòΪ˫ÒýºÅÀïµÄ±äÁ¿Ãû±»×ªÒåÁË£¬ÊÔÎÊ£¬³£Á¿ÔõôÄܱ»¸³ÖµÄØ£¿
²»¹ýPHPÖУ¬µ¥ÒýºÅÀïµÄ±äÁ¿Ãû¾Í²»»á±»×ªÒåÁË£¬ÉÏÃæµÄ´úÂë¸Ä³Éeval('$a=55;');ÕâÑù¾Íû´íÎóÁËŶ£¡
///////////// ......

phpÖеÄevalºÍJavaScriptÖеÄeval

phpÖеÄevalºÍJavaScriptÖеÄevalÇø±ð£º
Definition and Usage

¶¨ÒåºÍÓ÷¨
The eval() function evaluates a
string as PHP code.
eval()º¯ÊýµÄ×÷ÓÃÊÇ£º·µ»ØÓëPHP´úÂëÏà¶ÔÓ¦µÄ×Ö·û´®¡£
The string
must be valid PHP code and must end with semicolon.
Õâ¸ö×Ö·û´®±ØÐëÊÇÓÐЧµÄPHP´úÂ룬
²¢ÇÒ±ØÐëÒԷֺŽáÊø¡£
This function returns NULL unless a return statement is
called in the code string. Then the value passed to return is returned.
If there is a parse error in the code string, eval() returns FALSE.
³ý
ÁËÔÚ´úÂë×Ö·û´®ÖÐÇëÇó“·µ»ØÓï¾ä[return
statement]”µÄÇé¿ö£¬ÔÚÆäËüÇé¿öÏ£¬Õâ¸öº¯Êý¶¼½«·µ»Ø¿ÕÖµ[NULL]£»Èç¹ûÇëÇóÁË“·µ»ØÓï¾ä”£¬ÄÇôËü½«·µ»Ø±»´«µÝµ½“·µ»ØÓï¾ä”ÖеÄÖµ¡£Èç
¹ûÕâ¶Î´úÂë×Ö·û´®³öÏÖ´íÎó£¬eval()º¯Êý½«·µ»ØFalse¡£
eval()º¯Êý£¬Õâ¸öº¯Êý¿ÉÒÔ°ÑÒ»¸ö×Ö·û´®µ±×÷Ò»¸öJavaScript±í´ïʽһÑùÈ¥Ö´ÐÐËü¡£
¿ÉÒÔ½«×Ö·û´®µÄÐÎʽת»»³ÉÊýÖµÐ͵È
ob_start() ob_end_clean() ob_get_contents()
(2008-12-19 16:17:41)
תÔØ

±êÇ©£º
»º³åÇø
start
±äÁ¿
work
ob_sta ......

phpÖеÄevalºÍJavaScriptÖеÄeval

phpÖеÄevalºÍJavaScriptÖеÄevalÇø±ð£º
Definition and Usage

¶¨ÒåºÍÓ÷¨
The eval() function evaluates a
string as PHP code.
eval()º¯ÊýµÄ×÷ÓÃÊÇ£º·µ»ØÓëPHP´úÂëÏà¶ÔÓ¦µÄ×Ö·û´®¡£
The string
must be valid PHP code and must end with semicolon.
Õâ¸ö×Ö·û´®±ØÐëÊÇÓÐЧµÄPHP´úÂ룬
²¢ÇÒ±ØÐëÒԷֺŽáÊø¡£
This function returns NULL unless a return statement is
called in the code string. Then the value passed to return is returned.
If there is a parse error in the code string, eval() returns FALSE.
³ý
ÁËÔÚ´úÂë×Ö·û´®ÖÐÇëÇó“·µ»ØÓï¾ä[return
statement]”µÄÇé¿ö£¬ÔÚÆäËüÇé¿öÏ£¬Õâ¸öº¯Êý¶¼½«·µ»Ø¿ÕÖµ[NULL]£»Èç¹ûÇëÇóÁË“·µ»ØÓï¾ä”£¬ÄÇôËü½«·µ»Ø±»´«µÝµ½“·µ»ØÓï¾ä”ÖеÄÖµ¡£Èç
¹ûÕâ¶Î´úÂë×Ö·û´®³öÏÖ´íÎó£¬eval()º¯Êý½«·µ»ØFalse¡£
eval()º¯Êý£¬Õâ¸öº¯Êý¿ÉÒÔ°ÑÒ»¸ö×Ö·û´®µ±×÷Ò»¸öJavaScript±í´ïʽһÑùÈ¥Ö´ÐÐËü¡£
¿ÉÒÔ½«×Ö·û´®µÄÐÎʽת»»³ÉÊýÖµÐ͵È
ob_start() ob_end_clean() ob_get_contents()
(2008-12-19 16:17:41)
תÔØ

±êÇ©£º
»º³åÇø
start
±äÁ¿
work
ob_sta ......

PHP ÕýÔò±í´ïʽ×ÊÁÏ


¡¡Ã¿¸öPHP³ÌÐòÔ±¶¼ÖªµÀPHPÓÐÇ¿´óµÄÕýÔò±í´ïʽ¹¦ÄÜ£¬ÎªÁËÒÔºóµÄ¹¤×÷·½±ã£¬ÎÒ´ÓÍøÉÏÕûÀíÁ˹ØÓÚÕýÔò±í´ïʽµÄ×ÊÁÏ£¬·½±ãÒÔºó¹¤×÷ʱµÄ½øÐÐ×ÊÁϲéÔÄ¡£ 
¡¡¡¡ÕýÔò±í´ïʽ(regular expression)ÃèÊöÁËÒ»ÖÖ×Ö·û´®Æ¥ÅäµÄģʽ£¬¿ÉÒÔÓÃÀ´¼ì²éÒ»¸ö´®ÊÇ·ñº¬ÓÐijÖÖ×Ó´®¡¢½«Æ¥ÅäµÄ×Ó´®×öÌæ»»»òÕß´Óij¸ö´®ÖÐÈ¡³ö·ûºÏij¸öÌõ¼þµÄ×Ó´®µÈ¡£ 
¡¡¡¡ ¾ÙÀýÀ´Ëµ£¬ÕýÔò±í´ïʽµÄÒ»¸ö×îΪÆÕ±éµÄÓ¦ÓþÍÊÇÓÃÓÚÑéÖ¤Óû§ÔÚÏßÊäÈëµÄÓʼþµØÖ·µÄ¸ñʽÊÇ·ñÕýÈ·¡£Èç¹ûͨ¹ýÕýÔò±í´ïʽÑéÖ¤Óû§ÓʼþµØÖ·µÄ¸ñʽÕýÈ·£¬Óû§ËùÌîдµÄ±íµ¥ÐÅÏ¢½«»á±»Õý³£´¦Àí£»·´Ö®£¬Èç¹ûÓû§ÊäÈëµÄÓʼþµØÖ·ÓëÕýÔò±í´ïµÄģʽ²»Æ¥Å䣬½«»áµ¯³öÌáʾÐÅÏ¢£¬ÒªÇóÓû§ÖØÐÂÊäÈëÕýÈ·µÄÓʼþµØÖ·¡£Óɴ˿ɼûÕýÔò±í´ïʽÔÚWEBÓ¦ÓõÄÂß¼­ÅжÏÖоßÓоÙ×ãÇáÖصÄ×÷Óᣠ
ÕýÔò±í´ïʽ
¡¡¡¡ÊÇÓÉÆÕͨ×Ö·û£¨ÀýÈç×Ö·û a µ½ z£©ÒÔ¼°ÌØÊâ×Ö·û£¨³ÆΪԪ×Ö·û£©×é³ÉµÄÎÄ×Öģʽ¡£ÕýÔò±í´ïʽ×÷Ϊһ¸öÄ£°å£¬½«Ä³¸ö×Ö·ûģʽÓëËùËÑË÷µÄ×Ö·û´®½øÐÐÆ¥Åä¡£
¡¡¡¡¿ÉÒÔͨ¹ýÔÚÒ»¶Ô·Ö¸ô·ûÖ®¼ä·ÅÈë±í´ïʽģʽµÄ¸÷ÖÖ×é¼þÀ´¹¹ÔìÒ»¸öÕýÔò±í´ïʽ£¬¼´/expression/ 
ÆÕͨ×Ö·û
¡¡¡¡ÓÉËùÓÐÄÇЩδÏÔʽָ¶¨ÎªÔª×Ö·ûµÄ´òÓ¡ºÍ·Ç´òÓ¡×Ö·û×é³É¡£Õâ°üÀ¨ËùÓеĴóдºÍСд×Öĸ×Ö· ......

Aptana studio 2.0 +aptana php plugin 1.1

I’ve just updated Aptana Studio from 1.5 to 2.0 only to find out that the spectacular Aptana PHP plugin is not longer supported and its installation has been removed from the Install Additional Features view. However, with some tricks we can still install the old Aptana 1.5.1 in order to use it. Well, in fact we can even install Aptana PHP in Studio 2.0.
First, download Aptana Studio 2.0 and install it.
 When you reach the Install Additional Features after installing Aptana, close it, what we need is not here.
 
from the Help menu, click on Install New Software…
 add the Aptana PHP plugin update site. Click on the Add… button and type the url http://update.aptana.com/update/php
 
 
Choose the Aptana PHP 1.1 and install it. After restarting Studio, the Aptana PHP plugin will be installed and your php files will be handled by it.
 
 
As you can see on the Plugins Manager, Aptana PHP 1.1 is installed (the Duplicate lo ......

php ÖеÄÅÐ¶Ï ×ܽá

<?php
/* Åжϳ£Á¿ÊÇ·ñ´æÔÚ*/
if (defined('MYCONSTANT')) {
echo MYCONSTANT;
}
//ÅжϱäÁ¿ÊÇ·ñ´æÔÚ
if (isset($myvar)) {
echo "´æÔÚ±äÁ¿$myvar.";
}
//ÅжϺ¯ÊýÊÇ·ñ´æÔÚ
if (function_exists('imap_open')) {
echo "´æÔÚº¯Êýimag_open\n";
} else {
echo "º¯Êýimag_open²»´æÔÚ\n";
}
//ÅжÏÀàÊÇ·ñ´æÔÚ
if (class_exists('MyClass')) {
$myclass = new MyClass();
}
//ÅжÏÎļþÊÇ·ñ´æÔÚ
$filename = '/path/to/foo.txt';
if (file_exists($filename)) {
echo "The file $filename exists";
} else {
echo "The file $filename does not exist";
}
//ÅжÏÊý×éÖÐÊÇ·ñ´æÔÚij³ÉÔ±
$os = array("Mac", "NT", "Irix", "Linux");
if (in_array("Irix", $os)) {
echo "Got Irix";
}
//ÅжϱäÁ¿ÀàÐÍ
is_array()
is_bool()
is_float()
is_integer()
is_null()
is_numeric()
is_object()
is_resource()
is_scalar()
is_string()
?>  ......
×ܼǼÊý:2174; ×ÜÒ³Êý:363; ÿҳ6 Ìõ; Ê×Ò³ ÉÏÒ»Ò³ [4] [5] [6] [7] 8 [9] [10] [11] [12] [13]  ÏÂÒ»Ò³ βҳ
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ