Hello all,
I have an error in my PHP, trying to figure it out, could someone please help me out? Thanks for taking a look at this for me... This is not the whole page, had to cut some of the bottom to make it fit in this in this post.
ERROR:
Syntax error, unexpected T_CLONE, expecting T_STRING in ..... line 31
LINE 31 STARTING AT: function &clone( )
<?php
class url
{
var $scheme;
var $user;
var $pass;
var $host;
var $port;
var $path;
var $query;
var $fragment;
var $cache;
function url( $url = null )
{
if ( isset( $url ) )
{
$this->set( $url );
}
}
function set( $url )
{
$this->cache = null;
$url = $this->_encode( trim( $url ) );
$parts = $this->_parse_url( $url );
$this->_set_parts( $parts );
}
function &clone( )
{
$class = get_class( $this );
$clone =& new $class( );
foreach ( get_object_vars( $this ) as $key => $val )
{
$clone->$key = $val;
}
return $clone;
}
function equal_to( $url )
{
if ( !is_object( $url ) )
{
$url =& new url( $url );
}
if ( $this->is_absolute( ) != $url->is_absolute( ) )
{
return false;
}
if ( $this->get_port( true ) != $url->get_port( true ) )
{
return false;
}
if ( strcasecmp( $this->get_host( ), $url->get_host( ) ) !== 0 )
{
return false;
}
if ( strcasecmp( $this->get_scheme( ), $url->get_scheme( ) ) !== 0 )
{
return false;
}
$this_tmp = urldecode( $this->get_path( ) );
$url_tmp = urldecode( $url->get_path( ) );
if ( $this_tmp == "" )
{
$this_tmp = "/";
}
if ( $url_tmp == "" )
{
$url_tmp = "/";
}
if ( strcmp( $this_tmp, $url_tmp ) !== 0 )
{
return false;
}
$this_tmp = urldecode( $this->get_query( ) );
$url_tmp = urldecode( $url->get_query( ) );
if ( strcmp( $this_tmp, $url_tmp ) !== 0 )
{
return false;
}
return true;
}
function set_relative( $url )
{
$this->cache = null;
$url = $this->_encode( trim( $url ) );
$parts = $this->_parse_url( $url );
$this->fragment = isset( $parts['fragment'] ) ? $parts['fragment'] : null;
if ( $parts['path'] == "" && !isset( $parts['scheme'] ) || !isset( $parts['host'] ) || !isset( $parts['query'] ) )
{
return;
}
if ( isset( $parts['scheme'] ) )
{
$this->_set_parts( $parts );
}
else
{
$this->query = isset( $parts['query'] ) ? $parts['query'] : null;
if ( isset( $parts['host'] ) )
{
$this->host = $parts['host'];
$this->path = $parts['path'];
}
else
{
if ( isset( $this->host ) && $this->path == "" && strlen( $parts['path'] ) && substr( $parts['path'], 0, 1 ) != "/" )
{
$parts['path'] = "/".$parts['path'];
}
if ( substr( $parts['path'], 0, 1 ) == "/" )
{
$this->path = $parts['path'];
}
else
{
$buffer = substr( $this->path, 0, ( integer )strrpos( $this->path, "/" ) + 1 );
$buffer .= $parts['path'];
$buffer = str_replace( "/./", "/", $buffer );
if ( substr( $buffer, 0, 2 ) == "./" )
{
$buffer = substr( $buffer, 2 );
}
if ( substr( $buffer, -2 ) == "/." )
{
$buffer = substr( $buffer, 0, -1 );
}
$search_finished = false;
$segment = explode( "/", $buffer );
while ( !$search_finished )
{
$x = 0;
while ( $x + 1 < count( $segment ) )
{
if ( $segment[$x] != "" && $segment[$x] != ".." && $segment[$x + 1] == ".." )
{
if ( $x + 2 == count( $segment ) )
{
$segment[] = "";
}
unset( $segment->$x );
unset( $segment->$x + 1 );
$segment = array_values( $segment );
}
else
{
++$x;
}
}
$search_finished = true;
}
$buffer = count( $segment ) == 1 ? "/" : implode( "/", $segment );
$this->path = $buffer;
}
}
}
}
function get( )
{
return $this->as_string( );
}
function as_string( $fragment = URL_OPTION_WITH_FRAG )
{
if ( isset( $this->cache ) )
{
$url = $this->cache;
}
else
{
$url = "";
if ( isset( $this->scheme ) )
{
$url .= $this->scheme.":";
}
if ( isset( $this->host ) )
{
$url .= "//".$this->host;
if ( isset( $this->port ) )
{
$url .= ":".$this->port;
}
}
$url .= $this->path;
if ( isset( $this->query ) )
{
$url .= "?".$this->query;
}
if ( isset( $this->fragment ) )
{
$url .= "#".$this->fragment;
}
$this->cache = $url;
}
if ( $fragment == URL_OPTION_WITH_FRAG || !isset( $this->fragment ) )
{
return $url;
}
return substr( $url, 0, strpos( $url, "#" ) );
}
function is_absolute( )
{
return isset( $this->scheme );
}
function is_relative( )
{
return !$this->is_absolute( );
}
function get_scheme( )
{
if ( isset( $this->scheme ) )
{
return $this->scheme;
}
return false;
}
function get_user( )
{
if ( isset( $this->user ) )
{
return $this->user;
}
return false;
}
function get_pass( )
{
if ( isset( $this->pass ) )
{
return $this->pass;
}
return false;
}
function get_host( )
{
if ( isset( $this->host ) )
{
return $this->host;
}
return false;
}
Section in question starting at line 31
function &clone( )
{
$class = get_class( $this );
$clone =& new $class( );
foreach ( get_object_vars( $this ) as $key => $val )
{
$clone->$key = $val;
}
return $clone;
}