<?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. CAS实现的单点登录系统

    单点登录(single sign on ),简称SSO. 纯属学习用,对来自网络的部分如果侵害了您的权力,请联系我.QQ:262800095 SSO的定义是在多个应用系统中,用户只需要登录一次就可以访 ...

  2. Java基础——Servlet(六)分页相关

    前面写了Servlet(一)到(五),主要是在网上搜罗的视频.对分页这块还是不太清楚.于是有找到一些视频,重新学习了一下.主要是对分页的认识和设计思路.也是为了方便我以后回忆一下.. 一.分页常识 p ...

  3. 编程输出杨辉三角的前10行---多维数组的应用---java实现

    import java.util.Scanner;public class yanghui{ public static void main(String[] args){  Scanner sc=n ...

  4. 理解JVM之垃圾收集器详解

    前言 垃圾收集器作为内存回收的具体表现,Java虚拟机规范并未对垃圾收集器的实现做规定,因而不同版本的虚拟机有很大区别,因而我们在这里主要讨论基于Sun HotSpot虚拟机1.6版本Update22 ...

  5. Java系统和PHP系统相互调用

    一.HTTP JSON方式的缺点 JSON序列化效率低 多语言服务治理功能低 二.关于RPC框架 RPC 框架大致分为两类,一种是偏重服务治理,另一种侧重跨语言调用 2.1 服务治理型 特点 功能丰富 ...

  6. 手动创建script解决跨域问题(jsonp从入门到放弃)

    vue项目一般用axios代替jQuery发送ajax请求,但是不支持jsonp格式,需要安装jsonp的依赖包,这就很不爽了,能自己轻易实现的,为什么要引乱七八糟的插件.jsonp其实就是利用< ...

  7. Hystrix 框架

    雪崩效应的产生原因:当一个服务突然受到高并发的请求,tomcat服务器承受不了的情况下会产生服务堆积,可能导致其他的服务也不可用. 服务保护:当服务产生堆积的时候,对服务实现保护功能. 服务隔离:每个 ...

  8. short、int、long、float、double区别

    一.基本数据类型的特点,位数,最大值和最小值.1.基本类型:short 二进制位数:16 包装类:java.lang.Short 最小值:Short.MIN_VALUE=-32768 (-2的15此方 ...

  9. [基础架构]PeopleSoft Tuxedo 重要文件说明

    我们都知道PeopleSoft是由几个不同的服务组成的,他们在PeopleSoft体系结构中扮演着自己的角色.这些服务具有不同的文件结构并包含重要的可执行文件和配置文件. 以下是Peoplesoft体 ...

  10. VBoxManage翕令

    VBoxManage list vms VBoxManage startvm dcsvr08 -type vrdp VBoxHeadless -startvm "dcsvr08" ...