php - Unable to 'use' trait -


i'm attempting use traits first time. i'm unable use them. using trait when file trait exists in included results in following error:

parse error: syntax error, unexpected 'use' (t_use) in c:\xampp\htdocs\hyper\class_hyperheuristic.php on line 38

i'm using fancy way of requiring file , using traits:

 private function require_and_use_traits($number_of_heuristics){      for($t=1; $t<=$number_of_heuristics; $t++ ){         require_once __basepath__ . directory_separator . 'heuristic' . $t . '.php';         use heurisitc . $t;      }  } 

although manually requiring them results in same error; issue isn't loop.

performing following command within loop:

echo __basepath__ . directory_separator . 'heuristic' . $t . '.php'; 

displays valid path.

i'm using php 5.6.30 supports traits. suggest issue is?

you need use trait inside class, outside methods, parameter definition.

i suggest read traits documentation (thanks @axiac link)


Comments

Popular posts from this blog

What is happening when Matlab is starting a "parallel pool"? -

angular - DownloadURL return null in below code -

php - Cannot override Laravel Spark authentication with own implementation -