0

Can anyone explain why this isnt working?
I have two files index.php and include.php, the code for both are below, index includes the include.php but it doesnt output anything.
Include.php

<?php
class test {
var $two;
$this->two = 'variable 2';
function test1() {
$one = 'variable 1';
$testvar1 = $this->two;
$testvar1 .= $one;
return $testvar1;
}
function test2() {
 global $three;
 $three = 'variable three';
}

}
$test = new test;
?>

Index.php

<?php
include 'include.php';
$mine = $test->test1();
echo $mine;
$test->test2();
echo $three
echo "<html>me test</html>";
?>

Edited by mcatominey: n/a

2
Contributors
3
Replies
4
Views
7 Years
Discussion Span
Last Post by kylegetson
0

sorry, should have looked closer. your missing a semicolon on line 6 of your index.php file. Also, you can't use $this outside of a method in a class. If you want $this->two to be equal to 'variable 2', you need to do that in your declaration.

private $two = 'variable 2';
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.