- $host="localhost";
- $uname="데이터베이스 사용자 이름";
- $pass="데이터베이스 비밀번호" ;
- $database = "데이터베이스 이름";
- $connection=mysql_connect($host,$uname,$pass)
- 또는 die("데이터베이스 연결 실패");
-
- $result =mysql_select_db($database)
- or die("데이터베이스를 선택할 수 없습니다.");
-
- ?>
复主代码
- 함수 word_limit( $str, $num, $append_str='' ){
- $words = preg_split( '/[s] /', $str, -1, PREG_SPLIT_OFFSET_CAPTURE );
- if( isset($words[$num][1]) ){
- $str = substr( $str, 0, $words[$num][1] ).$append_str;
- }
- unset( $words, $num );
- return Trim( $str );>
- }
-
- echowords_limit($yourString, 50,'...' );
-
- 또는
-
- echowords_limit($yourString, 50);
제제대码
- 함수 video_image($url){
- $image_url =parse_url($url);
- if($image_url['host'] == 'www.youtube. com' ||
- $image_url['host'] == 'youtube.com'){
- $array =explore("&", $image_url['query']);
- return "http ://img.youtube.com/vi/".substr($array[0], 2)."/0.jpg";
- }else if($image_url['host'] == 'www. youtu.be' ||
- $image_url['host'] == 'youtu.be'){
- $array = 폭발("/", $image_url['path']);
- 반환 "http://img.youtube.com/vi/".$array[1]."/0.jpg";
- }else if($image_url['host'] == 'www.vimeo.com ' ||
- $image_url['host'] == 'vimeo.com'){
- $hash = unserialize(file_get_contents("http://vimeo.com/api/v2/video/".
- substr($image_url['path'], 1).".php"));
- return $hash[0]["thumbnail_medium"];
- }
- }
-
复代码
- 함수 age_from_dob($dob){
- $dob = strtotime($dob);
- $y = 날짜('Y', $dob);
- if (($m = (date('m') - date('m', $dob))) < 0) {
- $y ;
- } elseif ($m == 0 && date( 'd') - 날짜('d', $dob) < 0) {
- $y ;
- }
- 반환 날짜('Y') - $y;
- }
-
- echo age_from_dob('2005/04/19'); yyyy/mm/dd 형식의 날짜입니다.
复主代码
- //设置 쿠키
- setcookie("name", 'value', time() 3600*60*30);
- //显示 쿠키
- if ($_COOKIE["name"]!=""){
- $_SESSION['name'] = $_COOKIE["name"];
- }
复제代码
- //방법1
- echo substr(md5(uniqid()), 0, 8); <… @#%^&*()_,./<>?;:[]{}|= ';
-
- $str = '';
- $max = strlen($chars) - 1;
-
- for ($i=0; $i < $length; $i )
- $str .= $chars[rand(0, $max)];
- return $str;
- }
- echo rand_password(16);
- 复代码
-
date_default_timezone_set("아시아/캘커타"); function dt_differ($start, $end){ $start = date("G:i: s:m:d:Y", strtotime($start)); $date1=explode(":", $start); - $end = date("G:i:s: m:d:Y", strtotime($end));
- $date2=explode(":", $end);
-
- $starttime = mktime(date($date1[0]), 날짜($date1[1]),날짜($date1[2]),
- 날짜($date1[3]),날짜($date1[4]),날짜($date1[5]));
- $endtime = mktime(date($date2[0]),date($date2[1]),date($date2[2]),
- date($date2[3]),date($date2 [4]),date($date2[5]));
- $seconds_dif = $starttime-$endtime;
- return $seconds_dif;
- }
- 제조대码
- function second2days($mysec) {
- $mysec = (int)$mysec;
- if ( $mysec === 0 ) {
- return '0 초';
- }
- $mins = 0;
- $hours = 0;
- $days = 0;
- if ( $mysec >= 60 ) {
- $mins = (int)($mysec / 60);
- $mysec = $mysec % 60;
- }
- if ( $mins >= 60 ) {
- $hours = (int)($mins / 60);
- $mins = $mins % 60;
- }
- if ( $hours >= 24 ) {
- $days = (int) ($시간 / 24);
- $시간 = $시간 % 60;
- }
-
- $output = '';
-
- if ($일){
- $ 출력 .= $days." 일 ";
- }
- if ($hours) {
- $output .= $hours." hour ";
- }
- if ( $mins ) {
- $output .= $mins." 분 ";
- }
- if ( $mysec ) {
- $output .= $mysec." 초 ";
- }
- $output = rtrim($output);
- return $output;
- }
复代码
- $zip = zip_open("moooredale.zip");
- if ($zip) {
- while ($zip_entry = zip_read( $zip)) {
- $fp = fopen(zip_entry_name($zip_entry), "w");
- if (zip_entry_open($zip, $zip_entry, "r")) {
- $buf = zip_entry_read ($zip_entry, zip_entry_filesize($zip_entry));
- fwrite($fp,"$buf");
- zip_entry_close($zip_entry);
- fclose($fp);
- }
- }
- zip_close($zip);
- }
- ?>
复代码
|