Classes and Include PHP

0

Why do not you print anything?

main: index.php

<?php 

   include_once("teste.php");

   $a = new Teste();
   echo $a->foo();

Included file: test.php

<?php


   class Teste
   {
       private $teste;

        public function foo()
        {
           $this->teste = "adasdsad";
           return $this->teste;
        }
   } 
    
asked by anonymous 19.04.2016 / 21:21

1 answer

0

Add in the first few lines your file index.php :

error_reporting( E_ALL | E_NOTICE | E_STRICT );
ini_set( "display_errors" , '1' );
    
19.04.2016 / 23:04