Jump to content

Archived

This topic is now archived and is closed to further replies.

russia5

Parse error on

Recommended Posts

Hello group!  I have loaded a script off Zend Codex.  It is under security and it snuffs out injection of HTML and Java.

Problem is, I am getting this error.

Parse error: parse error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /home/russia5/public_html/submission-russian.php on line 26

Does anyone have an idea of why I am getting this?  Here is the code.  (I have bolded where line 26 is below)

Thanks to all that try to help!  Greg

[code]
class InputFilter {
    // class config vars
[b]line 26 is the one right below here[/b]

    private $tagsArray;      // required

[b]line 26 is right above here[/b]
    private $attrArray;        // default = empty array
    private $tagsMethod;  // default = 0
    private $attrMethod;        // default = 0
       
    /** 
      * Constructor for inputFilter class. Only first parameter is required.
      * @access constructor
      * @param Array $tagsArray - list of user-defined tags
      * @param Array $attrArray - list of user-defined attributes
      * @param int $tagsMethod - 0= allow just user-defined, 1= allow all but user-defined
      * @param int $attrMethod - 0= allow just user-defined, 1= allow all but user-defined
      */
    public function __construct($tagsArray, $attrArray = array(), $tagsMethod = 0, $attrMethod = 0) {       
        $this->tagsArray = $tagsArray;
        $this->attrArray = $attrArray;
        $this->tagsMethod = $tagsMethod;
        $this->attrMethod = $attrMethod;
    }
   
    /** 
      * Method to be called by another php script. 
      * @access public
      * @param Mixed $source - input string/array-of-string to be 'cleaned'
      * @return String $source - 'cleaned' version of input parameter
      */
    public function process($source) {
        if (is_array($source))    {                                                                                    // clean all elements in this array
            for ($i = 0; $i < count($source); $i++)
                if (is_string($source[$i])) $source[$i] = $this->remove($source[$i]);
            return $source;
        } else if (is_string($source)) return $this->remove($source);                            // clean this string
        else return $source;    class InputFilter {
    // class config vars
    private $tagsArray;      // required
    private $attrArray;        // default = empty array
    private $tagsMethod;  // default = 0
    private $attrMethod;        // default = 0
       
   
[/code]

Share this post


Link to post
Share on other sites
What version of PHP are you using? If its PHP4 then that code is not compatible with your version of PHP and this the reason why you are getting the above errors. It will only work on PHP5 as it is using PHP5 OO keyword/functions. These keyowrds/functions is not available for PHP4

The following keywords is not compatible for PHP4
public, protected, private

The following functions is not available for PHP4:
__construct, __destruct

Whejn defining a variable in OOP for PHP4 you use var instead of public, protected, or private, ge:
[code=php:0]var $myvar[/code]


The same for functions, to define a function in OOP for PHP4 you use:
[code=php:0]function myfunc(balh)[/code]

Note the lake of any public, protected, or private keywords before the function keyword.

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.