본문 바로가기

PHP

(11)
(함수) shuffle() & str_shuffle() - 랜덤함수 랜덤1 : shuffle() function random_password_1($cnt) { $word_en = "a,b,c,d,e,f,g,h,i,j,k,l,m,o,p,q,r,s,t,u,v,w,x,y,z"; $word_no = "1,2,3,4,5,6,7,8,9,0"; $word = $word_en.",".$word_no; $array=explode(",",$word); shuffle($array); $newstring = implode($array,""); return substr($newstring, 0, $cnt); } echo random_password_1('5'); 랜덤2 : str_shuffle() function random_password_2($cnt) { $word = 'abcefghijk..
(함수-정규식) preg_match() - 에디터 콘텐츠 이미지찾기 * 적용함수 * preg_match_all() * preg_match() * getimagesize() * filesize() function appImages($text){ global $_fileDir; global $_fileUrl; $img1 = array(); $img_cnt = preg_match_all("/]*src=[\"']?([^>\"']+)[\"']?[^>]*>/i", $text, $match); //이미지파일 html 추출 if($img_cnt > 0) { for ($i=0; $i 1){ for($i=0; $i
(함수) date() date() // set the default timezone to use. Available since PHP 5.1 date_default_timezone_set('UTC'); // Prints something like: Monday echo date("l"); // Prints something like: Monday 8th of August 2005 03:12:46 PM echo date('l jS \of F Y h:i:s A'); // Prints: July 1, 2000 is on a Saturday echo "July 1, 2000 is on a " . date("l", mktime(0, 0, 0, 7, 1, 2000)); /* use the constants in the format pa..
(함수) PHP5.3 Debug php5.3 debug call_user_method() -> call_user_func() 사용 call_user_method_array() -> call_user_func_array() 사용 ereg() -> preg_match() 사용 ereg_replace() -> preg_replace() 사용 eregi() -> preg_match() 함수에 'i' 옵션을 사용 preg_match("/^http:\/\/,1 100/i",$str) eregi_replace() -> preg_replace()함수에 'i' 옵션을 사용 split() -> preg_split() or explode() 사용 spliti() -> preg_split() 함수에 'i' 옵션을 사용 mysql_db_query() -> m..
(함수) JS, CSS 소스 압축(줄바꿈, 들여쓰기, 주석 제거) JS, CSS 소스 압축하기 http://www.refresh-sf.com/yui/ Html 소스 줄바꿈, 들여쓰기, 주석 제거
(합수)define() - 해당페이지 직접 접근 제어 define()와 defined()을 이용하여 직접 해당페이지 접근제어 define() : 상수를 등록하는 함수defined() : 상수가 등록되어 있는지 검사하는 함수 페이지구성예 index.htmlmenu.php (include file) 이용방법 index.html ("_NAME_" 이라는 상수를 등록한다) define("_NAME_", TRUE); menu.php ("_NAME_" 상수가 없는경우 페이지 실행을 제어한다) if(!defined("_NAME_")) exit;
(함수) isset(), empty(), isnull() 비교 isset(), empty(), isnull() 비교 value if($val) isset empty is_null $val = 1 True True False False $val = '' False True True False $val = '0' False True True False $val = 0 False True True False $val = NULL False False True True $val False False True True $val = array() False True True False $val = array(1) True True False False
(함수) getimagesize() getimagesize() $size_info = getimagesize($image_file); $size_info[0] : image width $size_info[1] : image height $size_info[2] : image format (ex, 1:GIF, 2:JPG, 3:PNG, 4:SWF, 5:PDF, 6:BMP, 7:TIFF(intel byte order), 8:TIFF(motolola byte order), 9:JPC, 10:JP2, 11:JPX) $size_info[3] : image size string (ex, height="200" width="300") 샘플테스트 $image_file = "test_001.jpg"; // width='180' height='171' $si..