<?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版本号

php 7.0.10

所报错误

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

解决方式

查阅资料,发现php7.0之后将不再支持与类名相同的构造方法,构造方法统一使用 __construct()。

改正后代码

<?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";
?>

Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP的更多相关文章

  1. pandas 使用panel 报错 Panel is deprecated and will be removed in a future version.

    Panel is deprecated and will be removed in a future version.The recommended way to represent these t ...

  2. Numpy版本问题,import tensorflow as tf 报警:“ FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'”

    tensorflow成功安装后 import tensorflow as tf 报警:“ FutureWarning: Passing (type, 1) or '1type' as a synony ...

  3. PHP 5.6 中 Automatically populating $HTTP_RAW_POST_DATA is deprecated and will be removed in a future version

    解决方法 找到php.ini  文件, 把always_populate_raw_post_data  修改为-1 就行了. always_populate_raw_post_data=-1

  4. php5.6 版本出现 Automatically populating $HTTP_RAW_POST_DATA is deprecated and will be removed in a future version 的错误

    解决方法是修改php.ini配置: ;always_populate_raw_post_data = -1 把前面的分号去掉 always_populate_raw_post_data = -1 然后 ...

  5. 关于nodejs DeprecationWarning: current URL string parser is deprecated, and will be removed in a future version. To use the new parser, pass option { useNewUrlParser: true } to MongoClient.connect.

    const mongoose = require('mongoose') mongoose.connect("mongodb://localhost:27017/study", { ...

  6. Deprecated: Automatically populating $HTTP_RAW_POST_DATA is deprecated and will be removed in a future version. To avoid this warning set 'always_populate_raw_post_data' to '-1' in php.ini and use the

    参考链接 解决方法: 修改 php.ini  : always_populate_raw_post_data = -1 PHP 5.6已经废弃了$HTTP_RAW_POST_DATA

  7. ECshop 在迁移到 PHP7 时遇到的兼容性问题

    在 PHP7 上安装 ECShop V2.7.3时,报错! Deprecated: Methods with the same name as their class will not be cons ...

  8. php7.0版本不再以类名命名构造函数

    <?php class Car { var $color = "add"; function Car($color="green") { $this-&g ...

  9. ECshop 迁移到 PHP7版本时遇到的兼容性问题,ecshopphp7

    ECshop 迁移到 PHP7版本时遇到的兼容性问题,ecshopphp7 在 PHP7 上安装 ECShop V2.7.3时,报错! Deprecated: Methods with the sam ...

随机推荐

  1. 数据结构与算法--最短路径之Floyd算法

    数据结构与算法--最短路径之Floyd算法 我们知道Dijkstra算法只能解决单源最短路径问题,且要求边上的权重都是非负的.有没有办法解决任意起点到任意顶点的最短路径问题呢?如果用Dijkstra算 ...

  2. 常见的NoSQL数据库

    NoSQL数据库发展迅猛,据说现在已经有上百种NoSQL数据库了,下面来了解下常见的一些NoSQL数据库 先来看张表,了解下典型的NoSQL数据库的分类 临时性键值存储 永久性键值存储 面向文档的数据 ...

  3. php中的static静态变量

    今天碰到了一个php的小试题,一直没有明白为什么第三次循环是static静态变量没有起作用呢?想了好久才明白原理. <?php class MyClass{ function add($b){ ...

  4. python内置函数每日一学 -- any()

    any(iterable) 官方文档解释: Return True if any element of the iterable is true. If the iterable is empty, ...

  5. BZOJ3351: [ioi2009]Regions(根号分治)

    题意 题目链接 Sol 很神仙的题 我们考虑询问(a, b)(a是b的祖先),直接对b根号分治 如果b的出现次数\(< \sqrt{n}\),我们可以直接对每个b记录下与它有关的询问,这样每个询 ...

  6. 【代码笔记】iOS-MBProgressHUD

    一,工程图. 二,代码. AppDelegate.h #import <UIKit/UIKit.h> #import "MBProgressHUD.h" @interf ...

  7. OSGI企业应用开发(十二)OSGI Web应用开发(一)

    前面文章中介绍了如何在OSGI应用中整合Spring和Mybatis框架,本篇文章开始介绍如何使用OSGI技术开发Web应用.对于传统的Java EE应用,应用中涉及到的Web元素无非就是Servle ...

  8. Android逆向 APK文件组成

    一 了解APK文件 我们知道Android系统能运行的程序是.apk文件格式,其实它就是一个压缩包而已,把.apk修改成.zip,然后解压就可以得到该apk内部的文件结构. PS: 既然可以把apk文 ...

  9. Android--解决EditText放到popupWindow中,原有复制、粘贴、全选、选择功能失效问题

    1.原来是将EditView放到了popupwindow,发现EditView原有的复制.粘贴.全选.选择功能失效了,所以便用DialogFragment代替了popupWindow 直接上代码 ①. ...

  10. mysql 安全模式

    今天,执行一条delete语句的时候报错如下: Error Code: 1175. You are using safe update mode and you tried to update a t ...