phpµÄsimpletest¿ò¼Ü¶ÔuchomeÏîÄ¿½øÐнӿڲâÊԽű¾
<?php
require_once ('unit_tester.php');
require_once ('reporter.php');
require_once ('../config.php');
require_once ('../source\modules\user\user_api.func.php');
require_once ('../source/base_model.class.php');
Class registertest extends UnitTestCase{
public function testAssertEqual(){
$base = new base_model();
$_ENV['base'] = $base;
$base->db->query("delete from uc_members where uid is not null");
$base->db->query("alter table uc_members AUTO_INCREMENT=1");
//testcase1
$this->assertEqual(1,$num=api_user_register("123","12","1234@12.cn"),"register success so ,expect result 1,reality:".$num.",line 15");
//testcase1
//testcase2
$this->assertEqual(-1,$num=api_user_register("12","321","1234@12.cn"),"register failed because of length of username fewer than 3 ,expect result -1,reality:".$num.",line 18");
//testcase2
//testcase3
$base->db->query("delete from uc_badwords");
$base->db->query("insert into uc_badwords(find,findpattern) values('²Ý','/²Ý/is')");
$this->assertEqual(-2,$num=api_user_register("3²Ýf","232s","sdasx@fs.com"),"api_user_register(3²Ýf,232s,sdasx@fs.com) ,register failed because of content bad words in it ,expect result -2,reality:".$num.",line 23");
//testcase3
//testcase4
$this->assertEqual(-1,$num=api_user_register("#@","dsx","sdxzc@fs.com"),"register failed because of unexpect symbols in username ,expect result -1,reality:".$num.",line 26");
//testcase4
//testcase5
$this->assertEqual(-1,$num=api_user_register(" Guest","098","sd78a@dscx.net"),"register failed becase of username content unexpected words as Guest ,expect result -1,reality:".$num.",line 28");
//testcase5
//testcase6
$this->assertEqual(-1,$num=api_user_register("sdads78778z23ws1","9890s","sd xa@83.com"),"register failed because of length of username more than 15 ,expect result -1,reality:".$num.",line 31");
//testcase6
//testcase7
$num=$base->db->result_first("select max(uid) from uc_members");
Ïà¹ØÎĵµ£º
PHPµÄÊý¾ÝÀàÐ͵Äת»»ÓÐÁ½ÖÖ·½·¨¿ÉÒÔ°ìµ½£ºÖ±½ÓÊäÈëÄ¿±êµÄÊý¾ÝÀàÐͺÍͨ¹ýsettypeº¯ÊýʵÏÖ¡£
PHPÊý¾Ýת»»³ÉÕûÊý
FloatÐÍÊý¾Ýת»»³ÉintÐÍ
FloatÐÍת»»³ÉintÐÍ£¬Ð¡ÊýµãºóµÄÊý½«±»ÉáÆú¡£Èç¹ûfloatÊý³¬¹ó³¬¹ýÁËÕûÐ͵Äȡֵ·¶Î§£¬ÄÇô½á¹û¿ÉÄÜÊÇ0»òÕßÊÇÕûÐεÄ×îС¸ºÊý¡£
ÀýÈ磺
<?php
$php = 1.59;
echo (int)$php.&rdquo ......
PHPÖÐͨ³£Óм¸ÖÖ×Ô¶¨Ò庯ÊýµÄ·½·¨£¬ÏÂÃæ½éÉÜһϣ¬ÎÒÃÇʹÓõÄÊÇÕâÖÖ·½Ê½£º
<?php
function foo($arg)
{
return $arg
}
?>
µ±Ä³Ð©²ÎÊýΪ¿ÉÑ¡ÊÇ£¬¿ÉÒÔÕâÑù¶¨Ò壺
<?php
function foo($arg = NULL)
{
return $arg == NULL ? "" : $arg;
}
?>
µ±ÎÒÃDz»ÏÞÖÆ²ÎÊý¸öÊýµÄʱºò£¬Ò²¿ÉÒ ......
PHPÓû§µÇ¼ģ¿éʵÏÖ
ÏîÄ¿°üº¬µÄ¹¦Äܽű¾£º
login.php//怬
reg.php//×¢²áÓû§
user_add.php//×¢²áУÑé½Å±¾
user_login_check.php//µÇ¼УÑé½Å±¾
image.php//ÑéÖ¤ÂëͼƬÉú³É½Å±¾
Á÷³Ì£º
Éè¼ÆÊý¾Ý¿â£º
°üº¬Óû§uid£¬Óû§Ãû£¬ÃÜÂ룬êdzƣ¬ÐÔ±ð£¬ÓÊÏ䣬ע²áʱ¼ä
sqlÓï¾äÈçÏÂ
create table users (uid bigint(20) ......
<?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 = ......
PHP´´½¨Îļþ£¨¼Ð£©ÒÔ¼°Ä¿Â¼²Ù×÷
Ò»¡¢Ä¿Â¼²Ù×÷
Ê×ÏÈÊÇ´ÓĿ¼¶ÁÈ¡µÄº¯Êý,opendir(),readdir(),closedir(),ʹÓõÄʱºòÊÇÏÈ´ò¿ªÎļþ¾ä±ú,¶øºóµü´úÁгö:
<?php
$base_dir="filelist/";
$fso=opendir($base_dir);
echo $base_dir."<hr/>";
whil ......