mercredi 8 février 2017

Not defined Substr in PHP

I tried substr() method in PHP 5.6 to get some part of String,

first,

<?php
    echo substr("Avicienna", 0,3);

and save it to a file.

second one,

<?php
    class Test{
        public function index(){
            $name = "Hasan";
            var_dump(subtr($name,0,3));
        }
    }

$test = new Test();
$test->index();

and save it to another file.

the first one without class, return correct string parts, while, the second one return PHP 500 error :

Call to undefined method Coba::subtr() in /var/www/html/koper/coba.php on line 5

is there any limitation to call substr() or others php function inside a class ?




Aucun commentaire:

Enregistrer un commentaire