Page 1 of 1

Include php script into php class

Posted: Wed Feb 10, 2010 6:49 am
by mellice
Hi there,
I've a php script in certain file called a.php, contains php script:
<?
$variable1 = 'hello world';
?>

Now I have a php class in other file named b.php, and I want to access the $variable1 into a method in this class

how can I do this?

thanks

Re: Include php script into php class

Posted: Wed Feb 10, 2010 7:03 am
by aravona
mellice wrote:Hi there,
I've a php script in certain file called a.php, contains php script:
<?
$variable1 = 'hello world';
?>

Now I have a php class in other file named b.php, and I want to access the $variable1 into a method in this class

how can I do this?

thanks
It should work using this:

Code: Select all

 
<?php
include("b.php");
$variable1 = 'hello world';
?>
Or

Code: Select all

 
<?php
include("a.php");
//your b file coding
?>
http://php.net/manual/en/function.include.php