Heya i've been trying to work out how a few new PHP tricks that i like are done so i've started building a little test script but i think i am going wrong somewhere in its implementation.

The script function is to get the value of the array passed to it by the class implementMethod and then just echo out if that is true or false.

If someone would be so kind to set me out on the right track please.

<?php
# Tells PHP to report all errors, not to be confused with displaying errors.
error_reporting(E_ALL);

# This one tells PHP to display errors.
ini_set('display_errors', 1);

namespace Cabbit;

class Validate
{    
private static $validationFunctions = array( 'validates_presence_of' ); } class implementMethod extends Cabbit \\ Validate { static $validates_precense_of = array( array("Title") ); }

    Well, the first thing I see is that...

    Namespaces are declared using the namespace keyword. A file containing a namespace must declare the namespace at the top of the file before any other code - with one exception: the declare keyword....The only code construct allowed before a namespace declaration is the declare statement, for defining encoding of a source file. In addition, no non-PHP code may precede a namespace declaration, including extra whitespace.

    (From "Defining namespace in the manual.)

      okies dokies sorted that bit 🙂

      Code now looks something like this, now if i wanted to make it so that the echo the static $validates_precense_of actually changed in the Validate class what would i be looking at doing, say a simple case switch exception. Do i just write in a function called validate and have it return a value that $validationFunctions will understand.

      <?php
      namespace Cabbit;
      
      # Tells PHP to report all errors, not to be confused with displaying errors.
      error_reporting(E_ALL);
      
      # This one tells PHP to display errors.
      ini_set('display_errors', 1);
      
      class Validate
      {    
      private static $validationFunctions = array( 'validates_presence_of' ); } class implementMethod extends Validate { static $validates_precense_of = array( array("Title") ); } echo implementMethod::$validates_precense_of;
        Write a Reply...