Detailed explanation of errors about PHP version number
<?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"; ?>
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";
?>
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!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

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

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

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

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

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.

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

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.

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

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
