Note that there are some explanatory texts on larger screens.

plurals
  1. POdeclare value of property as equal to that of parent
    primarykey
    data
    text
    <p>I have a parent class called 'person'. 'individual' is a child class of 'person'.</p> <p>In 'person', I have a protected property called '$_pk_person';</p> <p>In 'individual', I want to create a protected property called '$_fk_individual_person' whose value is equal to the inherited value of '$_pk_person'.</p> <p>Shouldn't I be able to do this by merely stating:</p> <pre><code>protected $_fk_individual_person = {$this-&gt;_pk_person}; </code></pre> <p>or</p> <pre><code>protected $_fk_individual_person = $_pk_person; </code></pre> <p>or</p> <pre><code>protected $_fk_individual_person = get_pk_person(); </code></pre> <p>or</p> <pre><code>protected $_fk_individual_person = self::get_pk_person(); </code></pre> <p>or</p> <pre><code>protected $_fk_individual_person = self::_pk_person; </code></pre> <p>or</p> <pre><code>protected $_fk_individual_person = parent::_pk_person; </code></pre> <p>or</p> <pre><code>protected $_fk_individual_person = parent::get_pk_person(); </code></pre> <p>in class 'individual'??</p> <p>None of them are working. I must be committing a fundamental error somewhere, as I am a complete novice.</p> <p>Please help me out.</p> <p>AFTER USING CONSTRUCTOR, my class looked like this:</p> <pre><code>class individual extends person { public $_fk_individual_person; function __construct() { $this-&gt;_fk_individual_person = $this-&gt;_pk_person; } } </code></pre> <p>And I tested it, but screen was blank: $xyz = new individual();</p> <pre><code>$xyz-&gt;pk_person='abcd'; echo $xyz-&gt;_fk_individual_person; </code></pre> <p>Where did I goof up now? I'm sorry, but I'm an absolute novice (started oop coding just yesterday, this being my first class)</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload