Table of Contents
form表单练习
回复内容:
Home Backend Development PHP Tutorial 用php5.2写的程序在切换到5.3之后出现notice错误???

用php5.2写的程序在切换到5.3之后出现notice错误???

Jun 06, 2016 pm 08:10 PM
php

以前一直用的是php5.2,但是最近发现版本略低,就切换成了php5.3(我用的是phpstudy组合包),但是在切换后,以前用php5.2写的程序就会出现notice提示,虽然不影响运行出正确结果。
用php5.2写的程序在切换到5.3之后出现notice错误???

图片描述

我以后应该用那种版本的php??我还是喜欢用组合包之类的

这是报错页面的代码:

<code><?php if(!empty($_POST)){
    $tt= $_POST['tt'];
    $id= $_POST['id'];
    $pwd= $_POST['pwd'];
    $wb= $_POST['wb'];
    $car= $_POST['car'];
    $yx= $_POST['yx'];
}
    echo "<br/>";
    // echo "<br>编程语言:$t33";    
    // print_r($t);
    echo "编程语言:";
    // 方法1:遍历数组,到那时最后的逗号无法避免
    // foreach ($t as $key => $value) {
    //     echo $value . ",";
    // }
    // 方法2:使用for循环
    $len=count($tt);//获得数组的长度
    $str="";
    for ($i=0; $i账号:$id";
    echo "<br>密码:$pwd";
    echo "<br>介绍:$wb";
    echo "<br>汽车:$car";
    echo "<br>院系:$yx";


?>
<form action="" method="POST" name="bb">
<table border="1">
<h2 id="form表单练习">form表单练习</h2>
<p id="lan">你喜欢那种<font>语言</font>?</p>
<input type="checkbox" name="tt[]" value="python"> python
<input type="checkbox" name="tt[]" value="javascript"> javascript
<input type="checkbox" name="tt[]" value="php" checked>php
<input type="checkbox" name="tt[]" value="swift"> swift
<hr>
<p>login in</p>
Account:<input type="text" name="id" value="">
Password:<input type="password" name="pwd" value=""><br>
<input type="submit" name="sub" value="login">
<input type="reset" name="re" value="cancel">
</table>
</form>

![图片描述][1]
我感觉不是代码的问题,还是因为php版本切换导致的,你说呢???
</code>
Copy after login
Copy after login

回复内容:

以前一直用的是php5.2,但是最近发现版本略低,就切换成了php5.3(我用的是phpstudy组合包),但是在切换后,以前用php5.2写的程序就会出现notice提示,虽然不影响运行出正确结果。
用php5.2写的程序在切换到5.3之后出现notice错误???

图片描述

我以后应该用那种版本的php??我还是喜欢用组合包之类的

这是报错页面的代码:

<code><?php if(!empty($_POST)){
    $tt= $_POST['tt'];
    $id= $_POST['id'];
    $pwd= $_POST['pwd'];
    $wb= $_POST['wb'];
    $car= $_POST['car'];
    $yx= $_POST['yx'];
}
    echo "<br/>";
    // echo "<br>编程语言:$t33";    
    // print_r($t);
    echo "编程语言:";
    // 方法1:遍历数组,到那时最后的逗号无法避免
    // foreach ($t as $key => $value) {
    //     echo $value . ",";
    // }
    // 方法2:使用for循环
    $len=count($tt);//获得数组的长度
    $str="";
    for ($i=0; $i账号:$id";
    echo "<br>密码:$pwd";
    echo "<br>介绍:$wb";
    echo "<br>汽车:$car";
    echo "<br>院系:$yx";


?>
<form action="" method="POST" name="bb">
<table border="1">
<h2 id="form表单练习">form表单练习</h2>
<p id="lan">你喜欢那种<font>语言</font>?</p>
<input type="checkbox" name="tt[]" value="python"> python
<input type="checkbox" name="tt[]" value="javascript"> javascript
<input type="checkbox" name="tt[]" value="php" checked>php
<input type="checkbox" name="tt[]" value="swift"> swift
<hr>
<p>login in</p>
Account:<input type="text" name="id" value="">
Password:<input type="password" name="pwd" value=""><br>
<input type="submit" name="sub" value="login">
<input type="reset" name="re" value="cancel">
</table>
</form>

![图片描述][1]
我感觉不是代码的问题,还是因为php版本切换导致的,你说呢???
</code>
Copy after login
Copy after login

这跟php版本没太大关系,而是你应该养成一个良好的编程习惯,不确定是否有值时要判断有才输出.

否则未关闭错误提示直接路径全部爆出来了

你应该改成:

<code>if(isset($user['yx'])){
    echo $user['yx'];
}

//或者

if(!empty($user['yx'])){
    echo $user['yx'];
}</code>
Copy after login

另外建议直接使用最新的稳定版本,截止到[2016/04/30]的LTS版本:5.6.21

跟版本没关系,变量没定义就使用,当然要报错!请一定注意,在使用非预定义变量的时候一定要先定义才能使用!

另外关于版本问题,根据市场份额和具体项目决定
目前建议在生产环境使用5.6
当然5.3用的最多 5.4其次
7速度最快

$tt没定义就用。而且这种没定义和版本无关,本来就会报错,只是php.ini的错误设置级别不同造成你以为5.2的就不报错

用isset先判断

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 AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

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)

CakePHP Project Configuration CakePHP Project Configuration Sep 10, 2024 pm 05:25 PM

In this chapter, we will understand the Environment Variables, General Configuration, Database Configuration and Email Configuration in CakePHP.

PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian Dec 24, 2024 pm 04:42 PM

PHP 8.4 brings several new features, security improvements, and performance improvements with healthy amounts of feature deprecations and removals. This guide explains how to install PHP 8.4 or upgrade to PHP 8.4 on Ubuntu, Debian, or their derivati

CakePHP Date and Time CakePHP Date and Time Sep 10, 2024 pm 05:27 PM

To work with date and time in cakephp4, we are going to make use of the available FrozenTime class.

CakePHP File upload CakePHP File upload Sep 10, 2024 pm 05:27 PM

To work on file upload we are going to use the form helper. Here, is an example for file upload.

CakePHP Routing CakePHP Routing Sep 10, 2024 pm 05:25 PM

In this chapter, we are going to learn the following topics related to routing ?

Discuss CakePHP Discuss CakePHP Sep 10, 2024 pm 05:28 PM

CakePHP is an open-source framework for PHP. It is intended to make developing, deploying and maintaining applications much easier. CakePHP is based on a MVC-like architecture that is both powerful and easy to grasp. Models, Views, and Controllers gu

How To Set Up Visual Studio Code (VS Code) for PHP Development How To Set Up Visual Studio Code (VS Code) for PHP Development Dec 20, 2024 am 11:31 AM

Visual Studio Code, also known as VS Code, is a free source code editor — or integrated development environment (IDE) — available for all major operating systems. With a large collection of extensions for many programming languages, VS Code can be c

CakePHP Creating Validators CakePHP Creating Validators Sep 10, 2024 pm 05:26 PM

Validator can be created by adding the following two lines in the controller.

See all articles