php ÖеıäÁ¿ ×÷ÓÃÓò
ѧ¹ýCµÄÈËÓÃphpµÄʱºòÒ»°ã»áÏ൱˳ÊÖ£¬¶øÇҸе½phpÌ«·½±ãÌ«ÇáËÉ¡£µ«ÔÚ±äÁ¿×÷ÓÃÓòÕâ·½ÃæÈ´Óë
cÓв»Í¬µÄµØ·½£¬¸ã²»ºÃ»áÏ൱ÓôÃÆ£¬¾ÍÕÒ²»µ½´íÎóËùÔÚ¡£×òÍí¾ÍÓëµ½Õâôһ¸öÎÊÌ⣬ÊÇÈ«¾Ö±äÁ¿ÔÚº¯ÊýÖеÄÎÊÌâ¡£½ñÌìËÑË÷ÁËһϣ¬·¢ÏÖһƪÏ൱²»´íµÄÎÄÕ£¬½²ÁËphpÖеıäÁ¿×÷ÓÃÓò¡£ÊÇһλÍøÓÑ·ÒëµÄ ÔÚÕâÌùһϣº
±äÁ¿·¶Î§
±äÁ¿µÄ·¶Î§¼´Ëü¶¨ÒåµÄÉÏÏÂÎı³¾°£¨ÒëÕß:˵°×ÁË£¬Ò²¾ÍÊÇËüµÄÉúЧ·¶Î§£©¡£´ó²¿·ÖµÄ PHP ±äÁ¿Ö»ÓÐÒ»¸öµ¥¶ÀµÄ·¶Î§¡£Õâ¸öµ¥¶ÀµÄ·¶Î§¿ç¶ÈͬÑù°üº¬ÁË include ºÍ require ÒýÈëµÄÎļþ¡£·¶Àý:
<?php
$a = 1;
include "b.inc";
?>
ÕâÀï±äÁ¿ $a ½«»áÔÚ°üº¬Îļþ b.inc ÖÐÉúЧ¡£µ«ÊÇ£¬ÔÚÓû§×Ô¶¨Ò庯ÊýÖУ¬Ò»¸ö¾Ö²¿º¯Êý·¶Î§½«±»ÒýÈë¡£ÈκÎÓÃÓÚº¯ÊýÄÚ²¿µÄ±äÁ¿°´È±Ê¡Çé¿ö½«±»ÏÞÖÆÔÚ¾Ö²¿º¯Êý·¶Î§ÄÚ¡£·¶Àý£º
<?php
$a = 1; /* global scope */
function Test()
{
echo $a; /* reference to local scope variable */
}
Test();
?>
Õâ¸ö½Å±¾²»»áÓÐÈκÎÊä³ö£¬ÒòΪ echo Óï¾äÒýÓÃÁËÒ»¸ö¾Ö²¿°æ±¾µÄ±äÁ¿ $a£¬¶øÇÒÔÚÕâ¸ö·¶Î§ÄÚ£¬Ëü²¢Ã»Óб»¸³Öµ¡£Äã¿ÉÄÜ×¢Òâµ½ PHP µÄÈ«¾Ö±äÁ¿ºÍ C ÓïÑÔÓÐÒ»µãµã²»Í¬£¬ÔÚ C ÓïÑÔÖУ¬È«¾Ö±äÁ¿ÔÚº¯ÊýÖÐ×Ô¶¯ÉúЧ£¬³ý·Ç±»¾Ö²¿±äÁ¿¸²¸Ç¡£Õâ¿ÉÄÜÒýÆðһЩÎÊÌ⣬ÓÐЩÈË¿ÉÄÜÂþ²»¾ÐĵĸıäÒ»¸öÈ«¾Ö±äÁ¿¡£PHP ÖÐÈ«¾Ö±äÁ¿ÔÚº¯ÊýÖÐʹÓÃʱ±ØÐëÉêÃ÷Ϊȫ¾Ö¡£
The global keyword
Ê×ÏÈ£¬Ò»¸öʹÓà global µÄÀý×Ó£º
Àý×Ó 12-1. ʹÓà global
<?php
$a = 1;
$b = 2;
function Sum()
{
global $a, $b;
$b = $a + $b;
}
Sum();
echo $b;
?>
ÒÔÉϽű¾µÄÊä³ö½«ÊÇ "3"¡£ÔÚº¯ÊýÖÐÉêÃ÷ÁËÈ«¾Ö±äÁ¿ $a ºÍ $b£¬ÈκαäÁ¿µÄËùÓÐÒýÓñäÁ¿¶¼»áÖ¸Ïòµ½È«¾Ö±äÁ¿¡£¶ÔÓÚÒ»¸öº¯ÊýÄܹ»ÉêÃ÷µÄÈ«¾Ö±äÁ¿µÄ×î´ó¸öÊý£¬PHP ûÓÐÏÞÖÆ¡£
ÔÚÈ«¾Ö·¶Î§ÄÚ·ÃÎʱäÁ¿µÄµÚ¶þ¸ö°ì·¨£¬ÊÇÓÃÌØÊâµÄ PHP ×Ô¶¨Òå $GLOBALS Êý×顣ǰÃæµÄÀý×Ó¿ÉÒÔд³É£º
Àý×Ó 12-2. ʹÓà $GLOBALS Ìæ´ú global
<?php
$a = 1;
$b = 2;
function Sum()
{
$GLOBALS["b"] = $GLOBALS["a"] + $GLOBALS["b"];
}
Sum();
echo $b;
?>
ÔÚ $GLOBALS Êý×éÖУ¬Ã¿Ò»¸ö±äÁ¿ÎªÒ»¸öÔªËØ£¬¼üÃû¶ÔÓ¦±äÁ¿Ãû£¬Öµ±äÁ¿µÄÄÚÈÝ¡£$GLOBALS Ö®ËùÒÔÔÚÈ«¾Ö·¶Î§ÄÚ´æÔÚ£¬ÊÇÒòΪ $GLOBALS ÊÇÒ»¸ö³¬È«¾Ö±äÁ¿¡£ÒÔÏ·¶ÀýÏÔʾÁ˳¬È«¾Ö±äÁ¿µÄÓô¦£º
Àý×Ó 12-3. ÑÝʾ³¬È«¾Ö±äÁ¿ºÍ×÷ÓÃ
Ïà¹ØÎĵµ£º
<!-- xml¸ñʽ
<foo xmlns="test">
<bar attr='a'></bar>
<bar attr='b'></bar>
<bar attr='c'></bar>
</foo>
-->
<?php
$dom = new DOMDocument();
if (!$dom->load('attr.xml'))
{
echo "load books.xml failed!<br>";
re ......
×î½ü·¢ÏֺܶàÍøÕ¾¶¼ÓÐһЩȦÈËÍ·ÏñµÄ¹¦ÄÜ£¬ºóÀ´ÔÚÍøÉÏGGÁËһϣ¬·¢ÏÖÊÇÓÃOpenCVʵÏֵģ¬ÎÒÒ²ÔÚÄÚ²¿·þÎñÆ÷×öÁËһϲâÊÔ£¬Èç¹û¿ÉÒÔʵÏÖ£¬²½ÖèÈçÏ£º
Ò» °²×°
1¡¢°²×°opencv
¹Ù·½ÍøÕ¾£ºhttp://www.opencv.org.cn £¨ÖÐÎİ棩
¾ßÌå°²×°·½·¨¿ÉÒԲο¼¹Ù·½ÍøÕ¾£º
http://www.opencv.org.cn/index.php/%E6%BA%90%E7%A0%81%E7% ......
<!-- xml ¸ñʽ
<books>
<book id='1001'>
<author>andylin</author>
<title>c language</title>
<publisher id="aaa">O'Reilly</publisher>
</book>
<book id='1002'>
<author>congfeng</author>
<t ......
$_SERVER´æ´¢µ±Ç°·þÎñÆ÷ÐÅÏ¢£¬ÆäÖÐÓм¸¸öÖµÈç$_SERVER["QUERY_STRING"]£¬$_SERVER["REQUEST_URI"]£¬$_SERVER["SCRIPT_NAME"]ºÍ$_SERVER["PHP_SELF"]³£³£ÈÝÒ×»ìÏý£¬ÒÔÏÂͨ¹ýʵÀýÏê½â$_SERVERº¯ÊýÖÐQUERY_STRING£¬REQUEST_URI£¬SCRIPT_NAMEºÍPHP_SELF±äÁ¿Çø±ð£¬ÕÆÎÕÕâËÄÕßÖ®¼äµÄ¹Øϵ£¬±ãÓÚÔÚʵ¼ÊÓ¦ÓÃÖÐÕýÈ·»ñÈ¡ËùÐèÒªµÄÖµ
1£ ......
JAVAÎļþ¶Áд±ØÐëҪעÒâ±àÂëÎÊÌâ
javaµÄÎļþд
Ö±½ÓʹÓÃFileWriter¼´¿É£¬µÚ¶þ¸ö²ÎÊýΪ׷¼ÓдÈ룬ĬÈÏÊǸ²¸Çд¡£Ð´Íê±ØÐëclose²Å»á±£´æдºÃµÄÄÚÈÝ¡£
ĬÈÏÇé¿öÈç¹ûûÓлáн¨Ò»¸öÎļþ
FileWriter fw = null;
try {
fw = new FileWriter("/data/updatetime.dat", true); // true×·¼ÓдÈë
fw.append ......