php ¶ÔÎļþ²Ù×÷
PHP´´½¨Îļþ£¨¼Ð£©ÒÔ¼°Ä¿Â¼²Ù×÷
Ò»¡¢Ä¿Â¼²Ù×÷
Ê×ÏÈÊÇ´ÓĿ¼¶ÁÈ¡µÄº¯Êý,opendir(),readdir(),closedir(),ʹÓõÄʱºòÊÇÏÈ´ò¿ªÎļþ¾ä±ú,¶øºóµü´úÁгö:
<?php
$base_dir="filelist/";
$fso=opendir($base_dir);
echo $base_dir."<hr/>";
while($flist=readdir($fso)){
echo $flist."<br/>";
}
closedir($fso)
?>
ÕâÊǽ²·µ»ØÎļþĿ¼ÏÂÃæµÄÎļþÒѾĿ¼µÄ³ÌÐò(0Îļþ½«·µ»Øfalse).
ÓÐʱºòÐèÒªÖªµÀĿ¼µÄÐÅÏ¢,¿ÉÒÔʹÓÃdirname($path)ºÍbasename($path),·Ö±ð·µ»Ø·¾¶µÄĿ¼²¿·ÖºÍÎļþÃûÃû³Æ²¿·Ö,¿ÉÓÃdisk_free_space($path)·µ»Ø²é¿´¿Õ¼äÊ£Óà¿Õ¼ä.
´´½¨ÃüÁî:
mkdir($path,0777)£º0777ÊÇȨÏÞÂë,ÔÚ·ÇwindowÏ¿ÉÓÃumask()º¯ÊýÉèÖÃ.
rmdir($path)£º½«É¾³ý·¾¶ÔÚ$pathµÄÎļþ.
¶þ¡¢Îļþ²Ù×÷
¡ñ н¨Îļþ
Ê×ÏÈ£¬È·¶¨ÄãËùҪн¨ÎļþËùÔÚµÄĿ¼ȨÏÞ; ½¨ÒéÉ豸Ϊ777¡£È»ºó£¬Ð½¨ÎļþµÄÃû³Æ½¨ÒéʹÓþø¶Ô·¾¶¡£
<?php
$filename="test.txt";
$fp=fopen("$filename", "w+"); //´ò¿ªÎļþÖ¸Õ룬´´½¨Îļþ
if ( !is_writable($filename) ){
die("Îļþ:" .$filename. "²»¿Éд£¬Çë¼ì²é£¡");
}
//fwrite($filename, "anything you want to write to $filename.";
fclose($fp); //¹Ø±ÕÖ¸Õë
¡ñ ¶ÁÎļþ
Ê×ÏÈÊÇÒ»¸öÎļþ¿´Äܲ»ÄܶÁÈ¡(ȨÏÞÎÊÌâ),»òÕß´æÔÚ²»,ÎÒÃÇ¿ÉÒÔÓÃis_readableº¯Êý»ñÈ¡ÐÅÏ¢.:
<?php
$file = 'dirlist.php';
if (is_readable($file) == false) {
die('Îļþ²»´æÔÚ»òÕßÎÞ·¨¶ÁÈ¡');
} else {
echo '´æÔÚ';
}
?>
ÅжÏÎļþ´æÔڵĺ¯Êý»¹ÓÐfile_exists(ÏÂÃæÑÝʾ),µ«ÊÇÕâ¸öÏÔÈ»ÎÞis_readableÈ«Ãæ.,µ±Ò»¸öÎļþ´æÔڵĻ°¿ÉÒÔÓÃ
<?php
$file = "filelist.php";
if (file_exists($file) == false) {
die('Îļþ²»´æÔÚ');
}
Ïà¹ØÎĵµ£º
¶¨ÒåºÍÓ÷¨
htmlspecialchars() º¯Êý°ÑһЩԤ¶¨ÒåµÄ×Ö·ûת»»Îª HTML ʵÌå¡£
Ô¤¶¨ÒåµÄ×Ö·ûÊÇ£º
& £¨ºÍºÅ£© ³ÉΪ &
" £¨Ë«ÒýºÅ£© ³ÉΪ "
' £¨µ¥ÒýºÅ£© ³ÉΪ '
< £¨Ð¡ÓÚ£© ³ÉΪ <
> £¨´óÓÚ£© ³ÉΪ >
Óï·¨
htmlspecialchars(string,quotestyle,character-se ......
Ò»£®¹ØÓÚMySQLÊý¾Ý¿â·þÎñÆ÷
MySQL·þÎñÆ÷µÄĬÈϱàÂëÊÇLatin1£¬²»Ö§³ÖÖÐÎÄ£¬ÄÇôÈçºÎÐÞ¸ÄMySQLµÄĬÈϱàÂëÄØ£¬ÏÂÃæÒÔUTF-8ΪÀýÀ´ËµÃ÷¡£
1¡¢ÖÐÖ¹MySQL·þÎñ£¨bin/mysqladmin -u root shutdown£©
2¡¢ÔÚ/etc/ÏÂÕÒµ½my.cnf£¬Èç¹ûûÓоͰÑMySQLµÄ°²×°Ä¿Â¼ÏµÄsupport-filesĿ¼ÏµÄmy-medium.cnf¸´ÖƵ½/etc/ϲ¢¸ÄÃûΪmy.cnf¼´¿É
......
±¾ÎÄÀ´×Ô¹úÍâµÄÒ»¸öPHP¼¼ÊõÈËÔ±ÍøÕ¾£¬×ܽáÁ˹úÍâµÄÊ®¸öÄ¿Ç°×îÁ÷ÐеÄPHP
MVC¿ò¼Ü¡£¾ßÌåÅÅÃû˳Ðòδ±Ø׼ȷ£¬»¹ÓÐЩ֪Ãû¿ò¼Ü£¬ÈçKohanaµÈҲûÓÐÌá¼°¡£²»¹ýÈÔ¿ÉÒÔ×öΪһƪ²»´íµÄ²Î¿¼¡£
ÒÔÏÂΪʮ¸öÄ¿Ç°×îÁ÷ÐеĻùÓÚMVCÉè¼ÆģʽµÄPHP¿ò¼Ü¡£
1. Yii
YiiÊÇÒ»¸ö»ùÓÚ×é¼þµÄ¸ßÐÔÄܵÄPHPµÄ¿ò¼Ü£¬ÓÃÓÚ¿ª·¢´ó¹æÄ£WebÓ¦Óá£Yii²ÉÓÃÑ ......
¡¡¡¡Ã¿´ÎÎÒÃÇ·ÃÎÊ PHP ½Å±¾µÄʱºò£¬¶¼Êǵ±ËùÓеÄPHP½Å±¾Ö´ÐÐÍê³Éºó£¬ÎÒÃDzŵõ½·µ»Ø½á¹û¡£Èç¹ûÎÒÃÇÐèÒªÒ»¸ö½Å±¾³ÖÐøµÄÔËÐУ¬ÄÇôÎÒÃǾÍҪͨ¹ý PHP ³¤Á¬½ÓµÄ·½Ê½£¬À´´ïµ½ÔËÐÐÄ¿µÄ¡£
¡¡¡¡Ã¿¸ö PHP ½Å±¾¶¼ÏÞÖÆÁËÖ´ÐÐʱ¼ä£¬ËùÒÔÎÒÃÇÐèҪͨ¹ý set_time_limit À´ÉèÖÃÒ»¸ö½Å±¾µÄÖ´ÐÐʱ¼äΪÎÞÏÞ³¤£»È»ºóʹÓà flush() ºÍ ob_flush() ......
<?php
define('SMARTY_TMP_DIR','C:/php5/Smarty-2.6.13/');
define('SMARTY_DIR','C:/php5/Smarty-2.6.13/libs/'); //SMARTY_DIR ->smarty keyword,must be defined as libs dectory
require_once(SMARTY_DIR.'Smarty.class.php');
//½¨Á¢Ò»¸ösmarty¶ÔÏó
$smarty = new Smarty;
$smarty->template_dir = ......