Require_once external vars and share those with other funcions in a php class
Posted
by frx08
on Stack Overflow
See other posts from Stack Overflow
or by frx08
Published on 2010-04-11T17:55:52Z
Indexed on
2010/04/11
18:03 UTC
Read the original article
Hit count: 281
Hi all, I have an external file with some vars to require in my php class and share those with all functions of my class:
vars.inc:
<?php
$a = 1;
?>
class.php:
<?php
class A{
public function __construct(){
require_once("vars.inc");
}
public function aB{
echo $a;
}
}
?>
but it doesn't work: the $a var is undefined
how can I do?
thanks all
© Stack Overflow or respective owner