Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

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Êý¾ÝÀàÐ͵Äת»»

PHPµÄÊý¾ÝÀàÐ͵Äת»»ÓÐÁ½ÖÖ·½·¨¿ÉÒÔ°ìµ½£ºÖ±½ÓÊäÈëÄ¿±êµÄÊý¾ÝÀàÐͺÍͨ¹ýsettypeº¯ÊýʵÏÖ¡£
PHPÊý¾Ýת»»³ÉÕûÊý
FloatÐÍÊý¾Ýת»»³ÉintÐÍ
FloatÐÍת»»³ÉintÐÍ£¬Ð¡ÊýµãºóµÄÊý½«±»ÉáÆú¡£Èç¹ûfloatÊý³¬¹ó³¬¹ýÁËÕûÐ͵ÄÈ¡Öµ·¶Î§£¬ÄÇô½á¹û¿ÉÄÜÊÇ0»òÕßÊÇÕûÐεÄ×îС¸ºÊý¡£
ÀýÈ磺
<?php
$php = 1.59;
echo (int)$php.&rdquo ......

phpÖе¥ÒýºÅºÍË«ÒýºÅÇø±ð

1 PHPÖе¥ÒýºÅÓëË«ÒýºÅµÄÇø±ð  
¡¡¡¡ÔÚPHPÖУ¬Í¨³£Ò»¸ö×Ö·û´®±»¶¨ÒåÔÚÒ»¶ÔÒýºÅÖУ¬È磺
'I am a string in single quotes'
"I am a string in double quotes"
¡¡¡¡PHPÓï·¨·ÖÎöÆ÷ÊÇÓóɶԵÄÒýºÅÀ´ÅжÏÒ»¸ö×Ö·û´®µÄ¡£Òò´Ë£¬ËùÓÐ×Ö·û´®±ØÐëʹÓÃͬһÖÖµ¥»òÕßË«
ÒýºÅÀ´¶¨Ò忪ʼºÍ½áÊø¡£ÀýÈ磬ÏÂÃæµÄ×Ö´®¶¨ÒåÊ ......

PHP ¶ÁдÎļþʾÀý


¡¡¡¡PHP ÖУ¬Êý¾Ýͨ³£¶¼ÊÇ´æ´¢ÔÚMySQLÊý¾Ý¿âµ±Öеġ£µ«ÊÇÓÐЩʱºò£¬ÎÒÃÇ»¹ÊÇÐèҪʹÓÃPHP¶ÁдһЩ±¾µØÎļþ¡£±ÈÈçÉú³É¾²Ì¬Ò³Ãæ»òÕßÊý¾ÝµÄ±¾µØ»º´æ¡£
¡¡¡¡ÎÒÃÇÓÃÒ»¸ö¼òµ¥µÄ·ÃÎÊÈÕÖ¾À´ÑÝʾһÏÂfopen, fread, fwrite, fcloseµÄÓ÷¨¡£
¡¡¡¡Ã¿µ±ÎÒÃÇ·ÃÎÊ´ËÍøÒ³µÄʱºò£¬»áÏÔʾ³ö·ÃÎʹýµÄIPÒÔ¼°·ÃÎÊʱ¼ä£»Í¬Ê±µ±Ç°µÄ·ÃÎÊÒ²»á±»¼Ç ......

PHPÓû§µÇ¼ע²áÄ£¿éʵÏÖ


PHPÓû§µÇ¼ģ¿éʵÏÖ
ÏîÄ¿°üº¬µÄ¹¦Äܽű¾£º
login.php//怬
reg.php//×¢²áÓû§
user_add.php//×¢²áУÑé½Å±¾
user_login_check.php//µÇ¼УÑé½Å±¾
image.php//ÑéÖ¤ÂëͼƬÉú³É½Å±¾
Á÷³Ì£º
Éè¼ÆÊý¾Ý¿â£º
°üº¬Óû§uid£¬Óû§Ãû£¬ÃÜÂ룬êdzƣ¬ÐÔ±ð£¬ÓÊÏ䣬ע²áʱ¼ä
sqlÓï¾äÈçÏÂ
create table users (uid bigint(20) ......

[PHP]PDOµ÷Óô洢¹ý³Ì

1. Êý¾Ý¿âÖÐÒÑ´´½¨´æ´¢¹ý³Ìuser_logon_check, PHPµ÷ÓÃʾÀýÈçÏÂ,
<?php
$dsn = 'mssql:dbname=MyDbName;host=localhost';
$user = 'sa';
$password = '666666';
try {
$dbCon = new PDO($dsn, $user, $password);
} catch (PDOException $e) {
print 'Connection failed: '.$e->getMessage();
......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ