Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP
<?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的更多相关文章
- 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 ...
- 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 ...
- 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
- 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 然后 ...
- 关于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", { ...
- 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
- ECshop 在迁移到 PHP7 时遇到的兼容性问题
在 PHP7 上安装 ECShop V2.7.3时,报错! Deprecated: Methods with the same name as their class will not be cons ...
- php7.0版本不再以类名命名构造函数
<?php class Car { var $color = "add"; function Car($color="green") { $this-&g ...
- ECshop 迁移到 PHP7版本时遇到的兼容性问题,ecshopphp7
ECshop 迁移到 PHP7版本时遇到的兼容性问题,ecshopphp7 在 PHP7 上安装 ECShop V2.7.3时,报错! Deprecated: Methods with the sam ...
随机推荐
- java图片压缩(Thumbnails)
package com.hzxc.groupactivity.server.util; import java.awt.image.BufferedImage; import java.io.*; i ...
- springboot学习-springboot使用spring-data-jpa操作MySQL数据库
我们在上一篇搭建了一个简单的springboot应用,这一篇将介绍使用spring-data-jpa操作数据库. 新建一个MySQL数据库,这里数据库名为springboot,建立user_info数 ...
- Linux常用基本命令(paste)
paste命令 作用:合并文件 格式: paste [option] [file] 1,把两个文件的内容,按行合并 ghostwu@dev:~/linux/paste$ ls ghostwu1.txt ...
- css之background-position属性实现雪碧图
什么是雪碧图 雪碧图就是CSS Sprite,也有人叫它CSS精灵,是一种CSS图像合并技术,就是把多张小图标合并到一张图片上,然后用css的background-position来显示需要显示的部分 ...
- css3 之 display 属性
1.定义 语法:display:none | inline | block | list-item | inline-block | table | inline-table | table-capt ...
- linux下安装mysql(ubuntu0.16.04.1)
安装步骤: sudo netstat -tap | grep mysql 查看是否已安装 安装mysql:sudo apt-get install mysql-server mysql-client ...
- 安卓开发环境配置之Windows+ADT+eclipse
安卓环境搭建之Windows+ADT+eclipse 要点: 1.安装JDK 2.安装Android SDK 3.安装eclipse 4.安装ADT 5.安装调试环境 正文: 1.安装JDK 1.1准 ...
- [Java][读书笔记]多线程编程
前言:最近复习java,发现一本很好的资料,<Java2参考大全 (第五版)> Herbert.Schildt.书比较老了,06年的,一些 ...
- Double Array Trie 的Python实现
不多介绍,可自行Google,或者其它关键词: "datrie" 放代码链接: double_array_trie.py 因为也是一段学习代码,参考的文章都记在里面了,主要参考gi ...
- 70部MAYA灯光材质渲染教程合集
MAYA灯光材质渲染教程合集 教程格式:MP4和flv 两种格式 使用版本:教程不是一年出的教程,各个版本都有 (教程软件为英文版) 清晰度:可以看清软件上的文字 语言:部分中文字幕,其他英文(通过看 ...