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_start
ob_end_clean
it
·ÖÀࣺ
php
ʹÓÃob_start()°ÑÊä³öÄÚÈÝÊä³öµ½»º³åÇø£¬¶ø²»Êǵ½ä¯ÀÀÆ÷¡£
È»ºóÓÃob_get_contentsµÃµ½»º³åÇøµÄÊý¾Ý¡£
ob_start()ÔÚ·þÎñÆ÷´ò¿ªÒ»¸ö»º³åÇøÀ´±£´æËùÓеÄÊä³ö¡£ËùÒÔÔÚÈκÎʱºòʹ
ÓÃecho
£¬Êä³ö¶¼½«±»¼ÓÈ뻺³åÇøÖУ¬Ö±µ½³ÌÐòÔËÐнáÊø»òÕßʹÓÃob_flush()À´½áÊø¡£È»ºóÔÚ·þÎñÆ÷Öлº³åÇøµÄÄÚÈݲŻᷢË͵½ä¯ÀÀÆ÷£¬ÓÉä¯ÀÀÆ÷À´½âÎöÏÔʾ¡£
º¯Êýob_end_clean
»áÇå³ý»º³åÇøµÄÄÚÈÝ£¬²¢½«»º³åÇø¹Ø±Õ£¬µ«²»»áÊä³öÄÚÈÝ¡£
´ËʱµÃÓÃÒ»¸öº¯Êýob_get_contents()ÔÚob_end_clean()Ç°ÃæÀ´»ñµÃ»º³åÇøµÄÄÚÈÝ¡£
ÕâÑùµÄ»°£¬
Äܽ«ÔÚÖ´ÐÐob_end_clean()Ç°°ÑÄÚÈݱ£´æµ½Ò»¸ö±äÁ¿ÖУ¬È»ºóÔÚob_end_clean()ºóÃæ¶ÔÕâ¸ö±äÁ¿×ö²Ù×÷¡£
ÕâÊÇEG£º
ob_start(); // buf1
echo ' multiple ';
ob_start(); // buf2
echo ' buffers work ';
$buf2 = ob_get_contents();
ob_end_clean();
$buf1 = ob_get_contents();
ob_end_clean();
echo $buf1;
echo '<br/>';
echo $buf2;
function
format_js($string ,$isjs){
$string =
addslashes(str_replace(array('\n','\r'),array('',''),$string));
return $isjs?'document.wirte("$string");':$str
Ïà¹ØÎĵµ£º
Primitive types
1. undefined, null, boolean, number, string; undefined is derived from null.
e.g. var tmp; typeof tmp == undefined.
e.g. void(javascript:aler(¡®x¡¯)) == undefined.
e.g. undefined==null
2. NaN!=NaN isNaN(¡°123¡±)==false isNaN(¡°blue¡±)==true ......
Ò³ÃæÒ»£º
<html>
<head>
<title> ÑéÖ¤ÓëÌá½»Ò» </title>
<script>
function focusSelect(ID) //µ±ÑéÖ¤²»ÄÜͨ¹ýʱ»ñµÃÑéÖ¤¿Ø¼þµÄ½¹µãºÍÄÚÈÝ
{
document.getElementById(I ......
×¢ÒâµÄÓм¸µã£¬hostedģʽÏÂRequestBuilder¶ÁÈ¡serverµÄjsonÓÐÎÊÌ⣬Óñ¾µØÎļþ´úÌæ¼´¿É¡£
Zend_JsonĬÈÏÊä³öµÄjsonÊý¾Ý²»Äܱ»¶ÁÈ¡£¬±ØÐë¼Ó[ºÍ]...
echo "[";
echo Zend_Json::encode($myconfig);
echo "]";
¼òµ¥¶ÁÈ¡jsonµÄÀý×Ó:
package com.esbrain.client;
import com.esbrain.sha ......
PHP±à³ÌÖо³£ÐèÒªÓõ½Ò»Ð©·þÎñÆ÷µÄһЩ×ÊÁÏ£¬ÌØ°Ñ$_SERVERµÄÏêϸ²ÎÊýÕûÀíÏ£¬·½±ãÒÔºóʹÓá£
$_server ´úÂë
1. $_SERVER['PHP_SELF'] #µ±Ç°ÕýÔÚÖ´Ðнű¾µÄÎļþÃû£¬Óë document rootÏà¹Ø¡£
2. $_SERVER['argv'] # ´«µÝ¸ø¸Ã½Å±¾µÄ²ÎÊý¡£
3. $_SERVER['argc'] # °üº¬´«µÝ¸ø³ÌÐòµÄÃüÁîÐвÎÊýµÄ¸öÊý£¨Èç¹ûÔËÐÐ ......
php evalº¯ÊýÓ÷¨----PHPÖÐeval()º¯ÊýС¼¼ÇÉ
eval
½«Öµ´úÈë×Ö·û´®Ö®ÖС£
Óï·¨: void eval(string code_str);
´«»ØÖµ: ÎÞ
º¯Ê½ÖÖÀà: Êý¾Ý´¦Àí
ÄÚÈÝ˵Ã÷
±¾º¯Ê½¿É½«×Ö·û´®Ö®ÖеıäÁ¿Öµ´úÈ룬ͨ³£ÓÃÔÚ´¦ÀíÊý¾Ý¿âµÄÊý¾ÝÉÏ¡£²ÎÊý code_str ΪÓû´¦ÀíµÄ×Ö·û´®¡£ÖµµÃ×¢ÒâµÄÊÇ´ý´¦ÀíµÄ×Ö·û´®Òª·ûºÏ PHP µÄ×Ö·û´®¸ñʽ£¬Í¬Ê±ÔÚ½ ......