Answers for "what are the possible ways to create objects in php"

PHP
2

php object example

<?php
class Bike
{
    function model()
    {
        $model_name = 'cd100';
        echo "bike model:$model_name";
    }
}
$obj = new Bike();
$obj->model();
?>
Posted by: Guest on September-03-2021
0

how to create object in php

//define a class
class MyClass{
  //create properties, constructor or methods
}

//create object using "new" keyword
$object = new MyClass();
 
//or wihtout parenthesis
$object = new MyClass;
Posted by: Guest on April-25-2020

Code answers related to "what are the possible ways to create objects in php"

Browse Popular Code Answers by Language