Home Backend Development PHP Tutorial Detailed explanation of errors about PHP version number

Detailed explanation of errors about PHP version number

Jul 21, 2017 pm 01:21 PM
deprecated methods name

<?php
class Car
{
    var $color = "add";
    function Car($color="green") {
        $this->color = $color;
    }
    function what_color() {
        return $this->color;
    }
}

$car = new Car;
echo $car->what_color(),"<br>over";
?>
Copy after login

PHP version number

php 7.0.10

Reported Error

Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; Car has a deprecated constructor in E:\phpStorm\firstPhp\test.php on line 8

Solution

#Check the information and find## After #php7.0, the constructor with the same name as the class will no longer be supported, and the constructor method will uniformly use __construct().

##Corrected code##

<?php
class Car
{
    public $color = "add";
    function __construct($color="green") {   //注意是双下划线$this->color = $color;
    }
    public function what_color() {
        return $this->color;
    }
}

$car = new Car("red");
echo $car->what_color(),"<br>over";
?>
Copy after login

The above is the detailed content of Detailed explanation of errors about PHP version number. For more information, please follow other related articles on the PHP Chinese website!

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

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

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)

PHP Deprecated: Function split() is deprecated - Solution PHP Deprecated: Function split() is deprecated - Solution Aug 17, 2023 pm 05:36 PM

PHPDeprecated: Functionsplit()isdeprecated-Solution When developing with PHP, we may encounter the following warning message: PHPDeprecated: Functionsplit()isdeprecated. What this warning means is that the split() function has been deprecated and its use is no longer recommended in the latest PHP versions. This article will explore this problem and provide solutions

php提交表单通过后,弹出的对话框怎样在当前页弹出,该如何解决 php提交表单通过后,弹出的对话框怎样在当前页弹出,该如何解决 Jun 13, 2016 am 10:23 AM

php提交表单通过后,弹出的对话框怎样在当前页弹出php提交表单通过后,弹出的对话框怎样在当前页弹出而不是在空白页弹出?想实现这样的效果:而不是空白页弹出:------解决方案--------------------如果你的验证用PHP在后端,那么就用Ajax;仅供参考:HTML code

Vue error: The function in methods cannot be used correctly, how to solve it? Vue error: The function in methods cannot be used correctly, how to solve it? Aug 18, 2023 pm 06:30 PM

Vue error: The function in methods cannot be used correctly, how to solve it? In the process of using Vue.js for front-end development, we often encounter the problem of being unable to use functions in methods correctly. This situation often occurs when we define a function but cannot call the function in the Vue component. This article will introduce some common error causes and solutions, and illustrate them with code examples. Error reason 1: The function is not correctly bound to the Vue instance when we use methods

PHP Deprecated: Methods with the same name solution PHP Deprecated: Methods with the same name solution Jun 24, 2023 pm 05:32 PM

During the development process using PHP, you may encounter the following prompt message: PHPDeprecated: Methodswiththesamename, and this prompt message often confuses program developers. So, what caused this problem? How to solve it? First, let's explain what this prompt message means. Deprecated, that is, "deprecated", refers to a function or method that is obsolete and is no longer an update in future versions of PHP.

PHP Deprecated: Function eregi() is deprecated - Solution PHP Deprecated: Function eregi() is deprecated - Solution Aug 17, 2023 pm 06:46 PM

PHPDeprecated: Functioneregi()isdeprecated-Solution As the PHP version is updated and iterated, some old functions are gradually deprecated, including function eregi(). This is a PHPDeprecated warning, meaning that using the eregi() function may cause problems in future versions. This article explains how to solve this problem and gives corresponding code examples. eregi() function

What should I do if php cannot get the name? What should I do if php cannot get the name? Nov 24, 2022 am 09:56 AM

PHP cannot get the name because when the name and id values ​​of the form element are different, the browser cannot recognize it. The solution: 1. Check whether some form elements and frame elements use name; 2. Check only Elements that can be assigned ID but not name; 3. For multi-select box checkbox, you can use "join(',', $__POST['name'])" to form data.

How to add name to setup in Vue3 How to add name to setup in Vue3 May 13, 2023 am 09:40 AM

What is the use of name in Vue3? 1. Name needs to be defined when making recursive components. 2. The component can be cached with keep-aliveincludeexclude. 3. When Vue reports an error or is debugging, you can see the name of the component. Vue3 defines name1. It is automatically generated as long as the setup syntax sugar mode single file component is turned on in the script. The corresponding name option will be automatically generated based on the file name. For example, Tree.vue, then its name will be automatically generated by Tree. This has a drawback. If you want to modify the name, you need to modify the component name. If there is a place to import the component, you need to modify it together. 2. Open a script to define name

PHP Deprecated: Function split() is deprecated in file.php on line X - Solution PHP Deprecated: Function split() is deprecated in file.php on line X - Solution Aug 19, 2023 pm 05:12 PM

PHPDeprecated:Functionsplit()isdeprecatinfile.phponlineX-Solution When developing and maintaining a PHP project, you will often encounter the prompt "PHPDeprecated:Functionsplit()isdeprecated". This is because PHP has deprecated spl as of version 5.3.0

See all articles