`

PHP常用问题开发集锦 -- vb2005xu亲身体验

阅读更多

今天在做开发时,无意中发现 PHP的方法名称 不区分大小写

 

比如 这两个函数 同时存在时报错误:

function LoadUserClassFile($file){
	$file = Class_Path . $file ;
	LoadFile($file);
}
function loadUserClassFile($file){
	$file = Class_Path . $file ;
	LoadFile($file);
}

 Fatal error: Cannot redeclare loaduserclassfile() (previously declared in webconf.php:64) in webconf.php on line 71

在使用cookie的时候报出了以下错误,很疑惑,找了半天才知道是参数类型传递错误.

function set_cookie($name = '', $value = '', $expire = null)
	{		
		setcookie(Cookies_Prefix.$name, $value, $expire, Cookies_Path, Cookies_Domain, 0);
	}

 $expire = null 它必须定义成null或者int类型 , 很多人采用''来赋初值,就会报错..  今天进一步发现,网上的文章其实也不可靠,书中的就更不行了

 

http://www.phpe.net/articles/20.shtml 被列入经典文章,,这个文章值得一读,怎么就没有书摘录它呢??

 

Warning: setcookie() expects parameter 3 to be long, string given in data.cookies.php on line 23

 

2
0
分享到:
评论
20 楼 vb2005xu 2010-01-11  
学习rails之HTML表单字段命令,比如user对象,可以
<form method="post" action="index" id="loginForm">
<input class="formfield" type="text" name="user[username]" value="admin" style="width:150px" /></td>
<input class="formfield" type="text" name="user[password]" value="admin" style="width:150px" /></td>
<input type="submit" class="formbutton" value=" 登 陆 " />
</form>


提交后
	

$_REQUEST :
Array
(
    [user] => Array
        (
            [username] => admin
            [password] => 1232112
        )

)


可以直接 $_REQUEST['user']来取,这样更好组织代码.. 呵呵
19 楼 vb2005xu 2010-01-04  
引用
PHP 5 Unable to Open HTTP Request Stream with fopen or fsockopen Functions


引用

With Apache/2.x.x or Apache/2.2.x webserver, with PHP5 as the scripting module, a HTTP communication error may occur within the PHP scripts that are parsing and running via the web server.

The errors that generated by PHP include:

PHP Warning: fopen(http://www.example.com): failed to open stream: HTTP request failed!
fsockopen(): unable to connect to …
file_get_contents(): failed to open stream: HTTP request failed!
PHP Warning: main(): Failed opening ‘http://www.example.com/index.html’ for inclusion …
PHP Warning: include(/usr/local/index.php): failed to open stream: No such file or directory in …

To resolve the problem, ensure that allow_url_fopen is enabled in PHP.INI configuration file. The line should look like this:

allow_url_fopen = On

Note: Depending on your system OS and configuration, the PHP.INI is located at various varied location, such as in Apache bin directory for Windows system or /usr/local/etc in FreeBSD Apache installation, if you don’t specify or point to PHP.INI in another directory.

If the error still happen and the PHP scripts still unable to connect to remote external servers and thus unable to download updates or retrieve files, check the user_agent setting in PHP.ini.

By default php.ini set the user_agent to “PHP” which signifies that it’s the script that try to access the web server. Some web servers will refuse and don’t allow script to access and receive the date from the server. So, by setting the user_agent to that of a web browser, PHP will let the web server know which kind of web browser will receive the date, and thus able to open the HTTP connection stream.

The user_agent can be set to any kind of browser strings, for example of Internet Explorer:

user_agent=”Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)”

18 楼 vb2005xu 2009-10-21  
引用

<b>Warning</b>:  date() expects parameter 2 to be long, string given in


是因为date函数第二个参数为string,强转成int就好了
date('Y-m-d h:i:s',(int)h($record[strtolower($columnMeta['name'])]) )
17 楼 vb2005xu 2009-10-20  

<?php
class SESE_DBO {
	var $tableName = null; 
	function init(){ //这个方法必须由子类显示调用
		$this->tableName = strtolower(get_class($this));
	}	
	/**
	 * 查询记录
	 * @param String $fields
	 */
	function select($fields=null){
		
		if (empty($fields))
			$fields = ' * ' ;
		//这个里面自己去实现	
		// select $fields from {$this->tableName}
	}
}

class News extends SESE_DBO {
	// 添加一些每个模块特殊的方法
}

$news = & new News();
$news->init();
var_dump($news->select());

?>
16 楼 vb2005xu 2009-08-12  
在windwos上设置php.ini中的 包含路径参数的正确写法:
引用

[include_path]
include_path="D:/AppServ/php5/library;.;"


要加引号

其中设置的路径,对于包含文件时查找的顺序有关
15 楼 vb2005xu 2009-07-28  
/** 简单的SQL字符串过滤函数 */
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;

  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? '"' . $theValue . '"' : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? '"' . doubleval($theValue) . '"' : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? '"' . $theValue . '"' : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}
function GetSQLValueStringForSelect($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;

  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? '"%' . $theValue . '%"' : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? '"' . doubleval($theValue) . '"' : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? '"' . $theValue . '"' : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}

?>

14 楼 vb2005xu 2009-07-24  
PHP版本的GZIP实现 -- 适用于WEB服务器不支持压缩选项的时候

摘自: http://www.julienlecomte.net/blog/2007/08/13/
<?php

ob_start();

/*
 * The mkdir function does not support the recursive
 * parameter in the version of PHP run by Yahoo! Web
 * Hosting. This function simulates it.
 */

function mkdir_r( $dir_name, $rights=0777 ) {
   $dirs = explode( "/", $dir_name );
   $dir = "";
   foreach ( $dirs as $part ) {
       $dir .= $part . "/";
       if ( !is_dir( $dir ) && strlen( $dir ) > 0 )
           mkdir( $dir, $rights );
   }
}

/*
 * List of known content types based on file extension.
 * Note: These must be built-in somewhere...
 */

$known_content_types = array(
    "htm"  => "text/html",
    "html" => "text/html",
    "js"   => "text/javascript",
    "css"  => "text/css",
    "xml"  => "text/xml",
    "gif"  => "image/gif",
    "jpg"  => "image/jpeg",
    "jpeg" => "image/jpeg",
    "png"  => "image/png",
    "txt"  => "text/plain"
);

/*
 * Get the path of the target file.
 */

if ( !isset( $_GET["uri"] ) ) {
    header( "HTTP/1.1 400 Bad Request" );
    echo( "<html><body><h1>HTTP 400 - Bad Request</h1></body></html>" );
    exit;
}

/*
 * Verify the existence of the target file.
 * Return HTTP 404 if needed.
 */

if (($src_uri = realpath( $_GET["uri"] )) === false) {
    /* The file does not exist */
    header( "HTTP/1.1 404 Not Found" );
    echo( "<html><body><h1>HTTP 404 - Not Found</h1></body></html>" );
    exit;
}

/*
 * Verify the requested file is under the doc root for security reasons.
 */

$doc_root = realpath( "." );

if (strpos($src_uri, $doc_root) !== 0) {
    header( "HTTP/1.1 403 Forbidden" );
    echo( "<html><body><h1>HTTP 403 - Forbidden</h1></body></html>" );
    exit;
}

/*
 * Set the HTTP response headers that will
 * tell the client to cache the resource.
 */

$file_last_modified = filemtime( $src_uri );
header( "Last-Modified: " . date( "r", $file_last_modified ) );

$max_age = 300 * 24 * 60 * 60; // 300 days

$expires = $file_last_modified + $max_age;
header( "Expires: " . date( "r", $expires ) );

$etag = dechex( $file_last_modified );
header( "ETag: " . $etag );

$cache_control = "must-revalidate, proxy-revalidate, max-age=" . $max_age . ", s-maxage=" . $max_age;
header( "Cache-Control: " . $cache_control );

/*
 * Check if the client should use the cached version.
 * Return HTTP 304 if needed.
 */

if ( function_exists( "http_match_etag" ) && function_exists( "http_match_modified" ) ) {
    if ( http_match_etag( $etag ) || http_match_modified( $file_last_modified ) ) {
        header( "HTTP/1.1 304 Not Modified" );
        exit;
    }
} else {
    error_log( "The HTTP extensions to PHP does not seem to be installed..." );
}

/*
 * Extract the directory, file name and file
 * extension from the "uri" parameter.
 */

$uri_dir = "";
$file_name = "";
$content_type = "";

$uri_parts = explode( "/", $src_uri );

for ( $i=0 ; $i<count( $uri_parts ) - 1 ; $i++ )
    $uri_dir .= $uri_parts[$i] . "/";

$file_name = end( $uri_parts );

$file_parts = explode( ".", $file_name );
if ( count( $file_parts ) > 1 ) {
    $file_extension = end( $file_parts );
    $content_type = $known_content_types[$file_extension];
}

/*
 * Get the target file.
 * If the browser accepts gzip encoding, the target file
 * will be the gzipped version of the requested file.
 */

$dst_uri = $src_uri;

$compress = true;

/*
 * Let's compress only text files...
 */

$compress = $compress && ( strpos( $content_type, "text" ) !== false );

/*
 * Finally, see if the client sent us the correct Accept-encoding: header value...
 */

$compress = $compress && ( strpos( $_SERVER["HTTP_ACCEPT_ENCODING"], "gzip" ) !== false );

if ( $compress ) {
    $gz_uri = "tmp/gzip/" . $src_uri . ".gz";

    if ( file_exists( $gz_uri ) ) {
        $src_last_modified = filemtime( $src_uri );
        $dst_last_modified = filemtime( $gz_uri );
        // The gzip version of the file exists, but it is older
        // than the source file. We need to recreate it...
        if ( $src_last_modified > $dst_last_modified )
            unlink( $gz_uri );
    }

    if ( !file_exists( $gz_uri ) ) {
        if ( !file_exists( "tmp/gzip/" . $uri_dir ) )
            mkdir_r( "tmp/gzip/" . $uri_dir );
        $error = false;
        if ( $fp_out = gzopen( $gz_uri, "wb" ) ) {
            if ( $fp_in = fopen( $src_uri, "rb" ) ) {
                while( !feof( $fp_in ) )
                    gzwrite( $fp_out, fread( $fp_in, 1024*512 ) );
                fclose( $fp_in );
            } else {
                $error = true;
            }
            gzclose( $fp_out );
        } else {
            $error = true;
        }

        if ( !$error ) {
            $dst_uri = $gz_uri;
            header( "Content-Encoding: gzip" );
        }
    } else {
        $dst_uri = $gz_uri;
        header( "Content-Encoding: gzip" );
    }
}

/*
 * Output the target file and set the appropriate HTTP headers.
 */

if ( $content_type )
    header( "Content-Type: " . $content_type );

header( "Content-Length: " . filesize( $dst_uri ) );
readfile( $dst_uri );

ob_end_flush();

?>
13 楼 vb2005xu 2009-06-26  
引用

天凡-郑州(54571365) 09:17:54
给大家分享一个新发现。5.2.0版及以后的PHP对setcookie增加了一个新参数,可以防止xss攻击
说明
bool setcookie ( string $name [, string $value [, int $expire=0 [, string $path [, string $domain [, bool $secure=false [, bool $httponly=false ]]]]]] )


httponly
When TRUE the cookie will be made accessible only through the HTTP protocol. This means that the cookie won't be accessible by scripting languages, such as JavaScript. This setting can effectively help to reduce identity theft through XSS attacks (although it is not supported by all browsers). Added in PHP 5.2.0. TRUE or FALSE
12 楼 vb2005xu 2009-06-02  
PHP数组分页的函数,性能有些提高

/**
 * 数组分页
 * @author vb2005xu.iteye.com
 * @param array $source
 * @param int $pernum
 */
function af($source,$pernum=15){
	if (!is_array($source))
	die('$source must a array');
	if (empty($GLOBALS['arr_source'])){
		$GLOBALS['arr_source'] = array_chunk($source,$pernum);
		$GLOBALS['arr_source']['pagenum'] = count($GLOBALS['arr_source']);
	}
}

$ta = range(0,87);
af($ta);

for($i=0;$i<$GLOBALS['arr_source']['pagenum'];$i++){
	print_r($GLOBALS['arr_source'][$i]);echo "<hr/>";
}
11 楼 vb2005xu 2009-04-23  

$str = '
[/url]  qtg [
[/url]gsgsbs   [
[/url]  gaagtw [
[/url] ff  [
[/url] gs  [
[/url]  wrw [
[/url] vaava  [
[/url]  aaaaaaaaaa [
[/url]  aac [

[/url][

' ;
//$str = preg_replace("/\[\/url\](.*)\[/Ui",'[/url][',$str) ;
10 楼 vb2005xu 2009-03-27  
PHP Access

<?  
$dbc=new com("adodb.connection");  
$dbc->open("driver=microsoft access driver (*.mdb);dbq=c:\member.mdb");  
$rs=$dbc->execute("select * from tablename");  
$i=0;  
while (!$rs->eof){  
$i+=1  
$fld0=$rs->fields["UserName"];  
$fld0=$rs->fields["PassWord"]; 
....  
echo "$fld0->value $fld1->value ....";  
$rs->movenext();  
}  
$rs->close();  
?> 

9 楼 vb2005xu 2009-03-10  
//使用dirname它并不在后面加上 / 字符,需要手动加上
FLEA::import(dirname(__FILE__) . '/inclib/app'); 
8 楼 vb2005xu 2009-03-04  
Smarty 循环如何把循环的次数显示出来?
<!--{foreach from=$users item=e}-->

<!--{/foreach}-->
7 楼 vb2005xu 2008-12-26  
与 字符串截取相关的 区分不同的字符集



<?php
/**
 * 与字符串相关的实用函数 集合 
 */

class Str_Util {
	/**
	 * 从指定的字符串中窃取指定长度的串
	 * 注意:	
	 * UTF8 汉字 3个字节 数字和字母都是 1 个字节 
	 * 使用mb_substr没有这个问题
	 * 
	 * 		  		 
	 * @param str $str_cut
	 * @param int $len
	 * @param int $charBytes
	 * @return str
	 */
	function substr_cut($str_cut='',$len=1,$charSet="UTF-8"){ 
		if(Str_Util::str_len($str_cut,$charSet)>$len){ 
			$str_cut = mb_substr($str_cut,0,$len,$charSet);
		} 
		return $str_cut; 
	}
	
	function str_convert($str_cut='',$sourceCharSet="UTF-8",$distCharSet="UTF-8")
	{
		return iconv($sourceCharSet,$distCharSet,$str_cut) ;
	}
	function str_len($str_cut='',$charSet="UTF-8")
	{
		return mb_strlen($str_cut,$charSet) ;
	}
	/**
	 * 语法高亮输出指定PHP文件--或者返回语法高亮的全文字符串
	 *
	 * @param str_filename $file
	 * @param bool $returnStr
	 * @return str
	 */
	function highlightStr($str,$returnStr=false)
	{
		if ( trim($str) != "" ){
			if ($returnStr)
				return highlight_string($str,true);
			else
				highlight_string($str) ;		
		}	    			
	}
}
?>

6 楼 vb2005xu 2008-12-25  
这里记录下自己整理的常用 文件操作 函数

<?php
/*
 * 与文件操作相关的函数 -- 一部分摘自 FleaPHP框架
 */

/**
 * 返回文件换行符
 * 例如 换行符--LINUX是\n windows是 \r\n Mac是 \r 
 * 这里要求注意 单引号与双引号的区别
 * 
 * @return String
 */
function getFileLineSepartor(){
	$lineSepartor = null ;
	switch(PHP_OS){
		case 'Linux':
			$lineSepartor = "\n" ;//单引号不转义
			break ;
		case 'WINNT':
			$lineSepartor = "\r\n" ;//单引号不转义
			break ;
		case 'FreeBSD':
			$lineSepartor = "\n" ;//单引号不转义
			break ;
	}
}

/**
 * safe_file_put_contents() 一次性完成打开文件,写入内容,关闭文件三项工作,并且确保写入时不会造成并发冲突
 *
 * @param string $filename
 * @param string $content
 * @param string $model 操作模式 缺省为 wb
 * @param int $flag
 *
 * @return boolean
 */
function safe_file_put_contents($filename, & $content,$model='wb')
{
    $fp = fopen($filename, $model);
    if ($fp) {
        flock($fp, LOCK_EX);
        fwrite($fp, $content);
        flock($fp, LOCK_UN);
        fclose($fp);
        return true;
    } else {
        return false;
    }
}

/**
 * safe_file_get_contents() 用共享锁模式打开文件并读取内容,可以避免在并发写入造成的读取不完整问题
 *
 * @param string $filename
 * @param string $model 操作模式 缺省为 rb
 *
 * @return mixed
 */
function safe_file_get_contents($filename,$model='rb')
{
    $fp = fopen($filename, $model);
    if ($fp) {
        flock($fp, LOCK_SH);
        clearstatcache();
        $filesize = filesize($filename);
        if ($filesize > 0) {
            $data = fread($fp, $filesize);
        } else {
            $data = false;
        }
        flock($fp, LOCK_UN);
        fclose($fp);
        return $data;
    } else {
        return false;
    }
}


/**
 * 创建一个目录树
 *
 * 用法:
 * <code>
 * mkdirs('/top/second/3rd');
 * </code>
 *
 * @param string $dir
 * @param int $mode
 */
function mkdirs($dir, $mode = 0777)
{
    if (!is_dir($dir)) {
        mkdirs(dirname($dir), $mode);
        return mkdir($dir, $mode);
    }
    return true;
}

/**
 * 删除指定目录及其下的所有文件和子目录
 *
 * 用法:
 * <code>
 * // 删除 my_dir 目录及其下的所有文件和子目录
 * rmdirs('/path/to/my_dir');
 * </code>
 *
 * 注意:使用该函数要非常非常小心,避免意外删除重要文件。
 *
 * @param string $dir
 */
function rmdirs($dir)
{
    $dir = realpath($dir);
    if ($dir == '' || $dir == '/' ||
        (strlen($dir) == 3 && substr($dir, 1) == ':\\'))
    {
        // 禁止删除根目录
        return false;
    }

    // 遍历目录,删除所有文件和子目录
    if(false !== ($dh = opendir($dir))) {
        while(false !== ($file = readdir($dh))) {
            if($file == '.' || $file == '..') { continue; }
            $path = $dir . DIRECTORY_SEPARATOR . $file;
            if (is_dir($path)) {
                if (!rmdirs($path)) { return false; }
            } else {
                unlink($path);
            }
        }
        closedir($dh);
        rmdir($dir);
        return true;
    } else {
        return false;
    }
}


/**
 * 向浏览器发送文件内容
 *
 * @param string $serverPath 文件在服务器上的路径(绝对或者相对路径)
 * @param string $filename 发送给浏览器的文件名(尽可能不要使用中文)
 * @param string $mimeType 指示文件类型
 */
function sendFile($serverPath, $filename, $charset='UTF-8', $mimeType = 'application/octet-stream')
{
	header("Content-Type: {$mimeType}");
    $filename = '"' . htmlspecialchars($filename) . '"';
    $filesize = filesize($serverPath);
    header("Content-Disposition: attachment; filename={$filename}; charset={$charset}");
    header('Pragma: cache');
    header('Cache-Control: public, must-revalidate, max-age=0');
    header("Content-Length: {$filesize}");
    readfile($serverPath);
    exit;
}
?>

5 楼 vb2005xu 2008-12-24  
PHP5与PHP4在定义数组时有些差异,一定要注意,总的来说PHP5屏蔽掉了很多不规范的语法引起的错误,但是PHP4也很好用. 个人呢比较喜欢PHP4,因为他和JAVA的语法很类似,很好转型.

1.
$arr = array(bb=>12); //PHP5

$arr = array('bb'=>12); //PHP4

PHP4中数组的非数字键值 必须使用 引号,否则报错

2. 在传递变量时 PHP传递是引用,PHP4传递的是值
要想在函数参数传递引用 应该 function (& $bbs){

}
这么定义
4 楼 vb2005xu 2008-12-24  
调试相关的函数,很好使用 -- 相对于使用print_r 或者 vars_dump来讲

/**
 * 输出变量的内容,通常用于调试
 *
 * @param mixed $vars 要输出的变量
 * @param string $label
 * @param boolean $return
 */
function dump($vars, $label = '', $return = false)
{
    if (ini_get('html_errors')) {
        $content = "<pre>\n";
        if ($label != '') {
            $content .= "<strong>{$label} :</strong>\n";
        }
        $content .= htmlspecialchars(print_r($vars, true));
        $content .= "\n</pre>\n";
    } else {
        $content = $label . " :\n" . print_r($vars, true);
    }
    if ($return) { return $content; }
    echo $content;
    return null;
}



3 楼 vb2005xu 2008-12-23  
与上传文件相关的属性和操作

1. 获得系统缺省设置上传文件的最大字节数:
intval(ini_get('upload_max_filesize'))

2. $_FILES属性详解
<form enctype="multipart/form-data" action="URL" method="post"> 
<input type="hidden" name="MAX_FILE_SIZE" value="1000"> 
<input name="myFile" type="file"> 
<input type="submit" value="上传文件"> 
</form> 



$_FILES数组内容如下:

$_FILES['myFile']['name']   客户端文件的原名称。 
$_FILES['myFile']['type']   文件的 MIME 类型,需要浏览器提供该信息的支持,例如"image/gif"。 
$_FILES['myFile']['size']   已上传文件的大小,单位为字节。 
$_FILES['myFile']['tmp_name']   文件被上传后在服务端储存的临时文件名,一般是系统默认。可以在php.ini的upload_tmp_dir 指定,但 用 putenv() 函数设置是不起作用的。 
$_FILES['myFile']['error']   和该文件上传相关的错误代码。['error'] 是在 PHP 4.2.0 版本中增加的。下面是它的说明:(它们在PHP3.0以后成了常量) 
  UPLOAD_ERR_OK 
    值:0; 没有错误发生,文件上传成功。 
  UPLOAD_ERR_INI_SIZE 
    值:1; 上传的文件超过了 php.ini 中 upload_max_filesize 选项限制的值。 
  UPLOAD_ERR_FORM_SIZE 
    值:2; 上传文件的大小超过了 HTML 表单中 MAX_FILE_SIZE 选项指定的值。 
  UPLOAD_ERR_PARTIAL 
    值:3; 文件只有部分被上传。 
  UPLOAD_ERR_NO_FILE 
    值:4; 没有文件被上传。 
    值:5; 上传文件大小为0. 





文件被上传结束后,默认地被存储在了临时目录中,这时您必须将它从临时目录中删除或移动到其它地方,如果没有,则会被删除。也就是不管是否上传成功,脚本执行完后临时目录里的文件肯定会被删除。所以在删除之前要用PHP的 copy() 函数将它复制到其它位置,此时,才算完成了上传文件过程。

2 楼 vb2005xu 2008-12-04  
在做一个小型的网站,想自己实现个微版的MVC,在分发器中发现在转到指定类或者调用指定类的属性或者方法不存在时会爆出错误,因此应做如下判断:

类是否存在,类属性或者方法是否存在?

要实现这三个目的,可以使用这三个方法

class_exists--检查类是否存在

method_exists--检查类的方法是否存在

property_exists--检查对象或类是否具有该属性
1 楼 vb2005xu 2008-12-03  
关于cookie的另一个问题: 第一次设置cookie值的时候取不出来,非要第二次才能读出来
不知道为什么?? 请高手答疑!

setcookie("mmm","bbb");

echo $_COOKIE["mmm"] ;

相关推荐

Global site tag (gtag.js) - Google Analytics