Avatar of Robert Granlund
Robert Granlund
Flag for United States of America asked on

Naming method inside of a Class

In MVC OOP  I am getting this warning:
Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; Data_model has a deprecated constructor in

Here is the class in my file data_model.php
Class Data_model extends CI_Model {

    function data_model() {
        $this->load->database();
        $this->table_name = 'data';
    }

Open in new window


How would I call how would you do it?
PHP* syntax

Avatar of undefined
Last Comment
Robert Granlund

8/22/2022 - Mon
gr8gonzo

Change:
function data_model() {
to
function __construct() {
Julian Hansen

You can read more about this here
http://php.net/manual/en/migration70.deprecated.php
ASKER CERTIFIED SOLUTION
Chris Stanyon

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Robert Granlund

ASKER
Thank you for explaining.  It makes sense now.
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck