I have the following class which simply takes what the user entered, and prints it. However it is giving me the following error:
Fatal error: Cannot access empty property in /home/mbecerra/domains/phpeaurl.co.cc/public_html/create.php on line 15
create.php
<?php
// include Smarty Library
include('libs/Smarty.class.php');
// include Url Class
include('libs/UrlBinder.class.php');
// create object
$smarty = new Smarty;
// create an instance of the Url class
$turlbinder = new UrlBinder();
// set the url
$urlbinder->$url = $_POST['url'];
// assign user entered url
$smarty->assign('url', $urlbinder->url);
// assign pea url value
$smarty->assign('peaurl', "http://" . $_SERVER['HTTP_HOST'] . '/1');
//send headers
header("Cache-Control: must-revalidate");
header("Content-Type: text/html;charset=utf-8");
// display it
$smarty->display('create.tpl');
?>
UrlBinder.class.php
<?php
# Name: UrlBinder.class.php
# File Description: Class to manage urls and shorturls
# Author: PHPeaURL
# Web: http://www.phpeaurl.co.cc/
# Update: 2010-03-01
# Version: 1.0.0
# Copyright 2010 phpeaurl.co.cc
/*
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
class UrlBinder {
// url
private $url;
// short url id
private $shortcode;
// ********************************************************************
// Description: gets the value of requested member property
// Parameters: member property which value is requested
// Returns: requested property members value
// ********************************************************************
public function __get($name) {
return $this->$name;
}
// ********************************************************************
// Description: sets the value of the requested member property
// Parameters: member property to set, value to set for member property
// ********************************************************************
public function __set($name, $value) {
// sanitize the value by removing whitespace, html tags and quoting strings with slashes
$this->$name = $value;
}
}
?>
Whats interesting is i have figured out that the line thats producing the error is:
// set the url
$urlbinder->$url = $_POST['url'];
However i don't see any problem with that line as its simply setting the property value. Any help in this matter would be greatly appreciated.
Sincerely,
PHPeaURL