![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 | |
|
Professional Programmer
Join Date: May 2006
Location: UK - London
Posts: 330
Rep Power: 3
![]() |
class errors
//SCRIPT NAME=evalcls.inc
<?php
class evalcls
{
$var=1;
}
?>INVOKED BY THIS SCRIPT //SCRIPT NAME=hello.php
<?php
include ("evalcls.inc");
$oj= new evalcls();
?>when i run this script i get this error; Parse error: parse error, unexpected T_VARIABLE, expecting T_FUNCTION in C:\wamp\www\evalcls.inc on line 4 I am using the WAMP 5 tool as my main tool and i am writing the scripts with the crimson editor. any help would be greately appreciated.
__________________
Quote:
|
|
|
|
|
|
|
#2 | |
|
Battle Programmer
Join Date: Feb 2006
Location: Bellevue, WA, USA
Posts: 763
Rep Power: 3
![]() |
<?php
class foo
{
$something = 1;
function __construct()
{}
}
$f = new foo();
?><?php
class foo
{
public $something = 1;
function __construct()
{
}
}
$f = new foo();
?>[edit:] confirmed: Quote:
__________________
<insert disclaimer here> <insert shameless plug for Visual Studio here> |
|
|
|
|
|
|
#3 | ||
|
Resident Grouch
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jun 2005
Posts: 6,453
Rep Power: 10
![]() |
From the manual:
Quote:
Quote:
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code. Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers |
||
|
|
|
|
|
#4 | |
|
Professional Programmer
Join Date: May 2006
Location: UK - London
Posts: 330
Rep Power: 3
![]() |
thanks a bunch dawei and jimbo, should of remebered that from my c++ days;
__________________
Quote:
|
|
|
|
|
|
|
#5 | |
|
Professional Programmer
Join Date: May 2006
Location: UK - London
Posts: 330
Rep Power: 3
![]() |
wait sorry hold the applause:
new problem: now the script is complaining about the next line in the script with the same error message: public $ret = 0;
if($ret==0) //its complaining about this line:
{
}and its giving this error message; Parse error: parse error, unexpected T_IF, expecting T_FUNCTION in C:\wamp\www\evalcls.inc on line 5 anymore replys would greately be appreciated
__________________
Quote:
|
|
|
|
|
|
|
#6 |
|
King of Portal
|
I believe the only change you need to make to your code is as follows:
class evalcls {
var $foo = 1;
}class evalcls {
public $foo;
function __construct() {
$this->foo = 1;
}
}
__________________
Lo, there do I see my father. 'Lo, there do I see My mother, and my sisters, and my brothers. 'Lo, there do I see The line of my people... Back to the beginning. 'Lo, they do call to me. They bid me take my place among them. In the halls of Valhalla... Where the brave... May live... ...forever.. GrimBB | Mimesis |
|
|
|
|
|
#7 |
|
King of Portal
|
Is that code located in your class or where exactly? 'Cause it wouldn't make sense to declare it as public if it's not in a class, which is what might be producing the error.
__________________
Lo, there do I see my father. 'Lo, there do I see My mother, and my sisters, and my brothers. 'Lo, there do I see The line of my people... Back to the beginning. 'Lo, they do call to me. They bid me take my place among them. In the halls of Valhalla... Where the brave... May live... ...forever.. GrimBB | Mimesis |
|
|
|
|
|
#8 | |
|
Professional Programmer
Join Date: May 2006
Location: UK - London
Posts: 330
Rep Power: 3
![]() |
sorry i should it made clear. that code is part of the class.
thanks.
__________________
Quote:
|
|
|
|
|
|
|
#9 | |
|
Professional Programmer
Join Date: May 2006
Location: UK - London
Posts: 330
Rep Power: 3
![]() |
i tried that and i am still getting the same error grimpirate.
__________________
Quote:
|
|
|
|
|
|
|
#10 |
|
Resident Grouch
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jun 2005
Posts: 6,453
Rep Power: 10
![]() |
if ($this->ret == 0)....
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code. Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Wierd compile Error. Need help please. | Keiyentai | Java | 7 | Aug 19th, 2006 1:35 AM |
| URL class | Eric the Red | Java | 5 | Jun 24th, 2006 9:01 PM |
| What is: "Oriented programming (OO)?" | BrinyCode | C++ | 12 | Nov 22nd, 2005 7:40 AM |
| User Input for Number Format | ericelysia1 | Java | 0 | Jul 21st, 2005 3:41 PM |
| Errors in microjava midlet | freddielj | Java | 1 | Apr 8th, 2005 11:02 AM |