Home Backend Development PHP Tutorial PHP4与PHP3中一个不兼容问题的解决方法_php基础

PHP4与PHP3中一个不兼容问题的解决方法_php基础

May 17, 2016 am 09:46 AM

PHP4与PHP3中有些不兼容的地方,但这主要是PHP4中的PHP.ini
中的设置有些不同的地方,这些改变主要是提高PHP4的效率。
其中的改变中,track_vars 的设置通常会是使旧的PHP3程序不能
再运行了,因为在PHP4的扩展设置中把track_vars 的值设为了off
这样旧的PHP3程序中就不能直接用GET,POST,COOKIE从上页传送过来
的变量了。

我这里有一个简单的解决的方法,不用把track_vars 的是设为on,
不过这只是一个权宜办法,以后大家还是用$HTTP_GET_VARS,  
$HTTP_POST_VARS and $HTTP_COOKIE_VARS读取这些变量比较好。

下面是一个简单的程序,大家可以加到每个需要读取GET,POST,COOKIE
的变量的页前,就可以直接引用这些变量了。

get.variable.inc.php


if(isset($HTTP_POST_VARS))
{
while ( list( $key, $val ) = each( $HTTP_POST_VARS ) )
{
$$key = $val;
}
}

if(isset($HTTP_GET_VARS))
{
while ( list( $key, $val ) = each( $HTTP_GET_VARS ) )
{
$$key = $val;
}
}


if(isset($HTTP_COOKIE_VARS))
{
while ( list( $key, $val ) = each( $HTTP_COOKIE_VARS ) )
{
$$key = $val;
}
}
?>  

请大家多多指教!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot Article Tags

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

11 Best PHP URL Shortener Scripts (Free and Premium) 11 Best PHP URL Shortener Scripts (Free and Premium) Mar 03, 2025 am 10:49 AM

11 Best PHP URL Shortener Scripts (Free and Premium)

Introduction to the Instagram API Introduction to the Instagram API Mar 02, 2025 am 09:32 AM

Introduction to the Instagram API

Working with Flash Session Data in Laravel Working with Flash Session Data in Laravel Mar 12, 2025 pm 05:08 PM

Working with Flash Session Data in Laravel

Simplified HTTP Response Mocking in Laravel Tests Simplified HTTP Response Mocking in Laravel Tests Mar 12, 2025 pm 05:09 PM

Simplified HTTP Response Mocking in Laravel Tests

cURL in PHP: How to Use the PHP cURL Extension in REST APIs cURL in PHP: How to Use the PHP cURL Extension in REST APIs Mar 14, 2025 am 11:42 AM

cURL in PHP: How to Use the PHP cURL Extension in REST APIs

Build a React App With a Laravel Back End: Part 2, React Build a React App With a Laravel Back End: Part 2, React Mar 04, 2025 am 09:33 AM

Build a React App With a Laravel Back End: Part 2, React

12 Best PHP Chat Scripts on CodeCanyon 12 Best PHP Chat Scripts on CodeCanyon Mar 13, 2025 pm 12:08 PM

12 Best PHP Chat Scripts on CodeCanyon

Notifications in Laravel Notifications in Laravel Mar 04, 2025 am 09:22 AM

Notifications in Laravel

See all articles