Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>From what I see - in the case where the flag is set, something has set it - there is no default value. The problem is not in the extending of <code>validate</code>, you just don't set the public property to any value before accessing it in <code>InsertINDB</code>. Eg in the first case <code>ValidateTypeOfMedia</code> is called, in the second, not.</p> <p>edit: OR <code>$SOEma == ""</code> in the second case evaluates to true and the <code>ValidateTypeOfMedia</code> does not set the flag to 1.</p> <p>BTW imho your code does not look right, not best practice, whatever you are trying to achieve (by no means trying to insult you).</p> <p>edit2: </p> <p>What is the result from those, I bet in both cases flag is not set:</p> <pre><code>$object_validate= new validate; $object_DB= new InsertINDB; $object_validate-&gt;whatever(); $object_DB-&gt;test(); </code></pre> <p>edit3:</p> <p>Khanquered Pro, based on your comment - you maybe do not understand the purpose of polymorphism. So to explain - after you extend the first class, you create an instance of the child (in your case InsertINDB). Then that instance holds all the methods (functions) and properties of validate. You can not first call validate in one instance, then expect its properties to be available in the child class - every instance is completely separated thing in this case, they have own property values (state). So after you extend <code>validate</code> you only work with the child - use it to validate, use it to insert to db. And you use the partent <code>validate</code> only in cases in the application where you need to validate data without inserting anything.</p> <p>I will not comment on if this whole architecture is good idea - its beyond the scope of the question and probably your current knowledge, but after you succeed with your task, read more on the topic of OOP as a start.</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.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      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