Question about OOP

Started on the old forum in May 2010 · view the original in the archive · old links redirect here

3 replies · 520 views · started 16 years ago · 1 min read

3 participants
kevk3v Senior · 332 posts #1

Why do i get an unexpected function error in this code?

<?php
class function {
function test() {  $var = "test";  echo $var;  }
}
$test = new function();
echo $test->test(); ?>

Mobile chat, iphone chat, android chat, chat, rooms http://www.aiochat.com

GumSlone Administrator Principal · 1,690 posts #2
<?php

class myclass {
function test() {  $var = "test";  echo $var;  }
}
$test = new myclass;
echo $test->test();

?>

Advertise your mobile site for FREE with AdTwirl

External image (may be gone)

Sign in to reply.

Similar topics

Keyboard shortcuts

g f
Go to forums
g h
Go to your feed
g m
Go to messages
r
Reply (in a topic)
/
Search
j
Next post
k
Previous post
?
This list
Ctrl/⌘ + Enter
Send what you are writing
Ctrl/⌘ + B / I
Bold / italic while writing
Esc
Close