samedi 2 janvier 2021

How to access function value in another function in PHP Classes

How can i return a variable value from one function and pass it to another function in a class and access it ?, im new to php class.

here is the code i have tried

<?php
class BioTool{
public function one(){
$lol =[2,3,5]; print_r($lol);
}
 public function two(){
     $newarr=$this->one(); //this only return the array but i can't access it, check below.
    print_r($newarr[0]); //not working
}
}

$biotool=new BioTool();
$biotool->two();


via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire