Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 1 of 1

Thread: class def error

  1. #1
    Regular Coder
    Join Date
    Aug 2010
    Location
    Now Southern Oregon. I was born and had lived my life in Los Angeles until relocating last year (2010)
    Posts
    215
    Thanks
    52
    Thanked 1 Time in 1 Post

    class def error

    Hello:
    I am developing what I expect to be a standalone picture viewer app.
    The following is the current state of the class def (php v5x)
    Code:
    <?php
    class PIX_VIEWER
          {
           private static $_classPath = '/Library/WebServer/Documents/whitecloud/WC_php/'; // absolute path to this file
           private static $_common = 'WC_common.php'; // master list of departments and subdepartments.
           private static $_templates = array();      // css, js source markup templates & display markup templates
           private static $_targets = array();        // template string str_replace targets
           private static $_cssCommon = '';           // common css file path
           private static $_cssCommonFiles = array(); // list of common css files to source
           private static $_cssSpec = '';             // specific css file path
           private static $_cssSpecFiles = array();   // list of specific css files to source
           private static $_jsCommon = '';            // common js file path
           private static $_jsCommonFiles = array();  // list of common js files to source
           private static $_jsSpec = '';              // specific js file path
           private static $_jsSpecFiles = array();    // specific js files to source
           private static $_cssIds = array();         // contextual css/javascript id attribute values
           private static $_localFile = '';           // local temp file, depending on department
           private static $_localSections = array();  // local sections and subsections
           private static $_errors = '';              // error strings for __construct failures
           
           public function __construct($_subDep)
                  {
                   $this->subDep = $_subDep;
                   if(file_exists(self::$_classPath.self::$_common))
                     {
                      require(self::$_classPath.self::$_common);
                      self::$_localFile = $_sectionsSrc[$this->subDep].'WC_template.php';
                      self::$_localSections = $_sections;
                      if(file_exists(self::$_localFile))
                        {
                         require_once(self::$_localFile);
                         self::$_templates = $_template;
                         self::$_targets = $_targetStrings;
                         self::$_cssCommon = $_CSS_commonSrcPath;
                         self::$_cssCommonFiles = $_CSS_commonFiles;
                         self::$_cssSpec = $_CSS_specSrcPath;
                         self::$_cssSpecFiles = $_CSS_specFiles;
                         self::$_jsCommon = $_JS_commonSrcPath;
                         self::$_jsCommonFiles = $_jsCommonFiles;
                         self::$_jsSpec = $_JS_specSrcPath;
                         self::$_jsSpecFiles = $_jsSpecFiles;
                         self::$_cssIds = $_cssIds;
                        }
                      else
                        {
                         self::$_errors .= 'local source file not found';
                        }
                     }
                   else
                     {
                      self::$_errors .= 'Common source file not found:';
                     }
                  }
                  
           public function getCss()
                  {
                   /*
                    string replace css src target for each item in css source file arrays.
                    accumulate source markup strings
                   */
                   return $this->cssSrc;
                  }
                 
           public function getJs()
                  {
                   /*
                    string replace js src target for each item in js source file arrays.
                    accumulate source markup strings
                   */
                   return $this->jsSrc;
                  }
                  
           public function getMrkUp()
                  {
                   /*
                    string replace markup target for each item in markup template.
                   */
                   return $this->mrkUp;
                  }
          }
    ?>
    In the following file, I am testing it for syntax errors and have encountered the error returned by php (as comment)
    Code:
    <?php
    if(file_exists('WC_php/pixViewerApp.php'))
      {
       require('WC_php/pixViewerApp.php');
       $_test = new PIX_VIEWER('cat');
       print $_test.errors;
       // Catchable fatal error: Object of class PIX_VIEWER could not be converted to string in /Library/WebServer/Documents/whitecloud/tester.php on line 6
      }
    ?>
    I am not sure why I am getting this error. Is it because of the array declarations as static variables?
    I have taken this approach successfully in the past.
    Thank you for time, attention, and thoughts.
    JK

    Um....PS, I'm sorry, I think I know why as I compose this and I don't know how to cancel the post.
    self::$_errors is declared private, so I have to include a public method to retrieve the value.
    Yuk, I am getting javascript syntax mixed up with php syntax.
    Code:
    print $_test.errors;
    should be
    Code:
    print $_test->errors;
    Last edited by anotherJEK; 02-22-2012 at 02:29 AM.


 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •