Jump to content

a question about function __construct()


Dougget

Recommended Posts



<?php
$jimmy = new person("Nick Giggings");


$number->set_pinn_number("345678");

$stefan = new person("Stefan Mischook");

echo "Stefan's full name: " . $stefan->get_name()."
";
echo "Nick's full name: " . $jimmy->get_name();

echo "Tell me private stuff: " . $number->get_pinn_number;

echo "hello";
?>
Link to comment
Share on other sites

You're calling the set_pinn_number method on the $number instance, which you haven't instantiated. You should do this instead:

 

$jimmy->set_pinn_number("345678");

 

Then, later on:

 

echo "Tell me private stuff: " . $jimmy->get_pinn_number;

 

See how you get on with that.

Edited by monkeysaurus
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...