Jump to content

OOP PHP query about tutorial error


Recommended Posts

I'm just starting to learn OO php after realising that it's what I need to go into contracting properly.

 

I think I understand the concepts but get an error Parse error: syntax error, unexpected T_NEW in C:\xampp\htdocs\ooprogramming\mainpage.php on line 13

 

Doesn't seem to be anything different to the example, it's a bit puzzling?

 

Thanks,

 

################## Mainpage.php #########################################

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"

"http://www.w3.org/TR/html4/loose.dtd">

<html>

<head>

</head>

<body>

<?php

include ("class_lib.inc");

$stefan new person("stefan mishook");

echo "stefs full name is " . $stefan->get_name();

?>

</body>

</html>

############# class #########################################

<?php

class person

{

 

var $name;

 

function __construct($persons_name)

{

$this->name = $persons_name;

}

 

function set_name($new_name)

{

$this->name = $new_name;

}

 

function get_name()

{

return $this->name;

}

 

}

 

 

class employee extends person

{

 

function __construct($employeename) {

 

$this->set_name($employee_name) ;

}

 

}

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...