Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: :arrow: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
I created a class and passed an integer to its constructor. When I instantiate the class, I find the integer has suddenly become a string...and not the same number respresented as a string. Instead I get a piece of a long string that I used elsewhere in the program. How is this possible? Why doesn't the constructor see the integer that's passed to it?
Here's my code:Code: Select all
if(isset($_REQUEST['page_id'])) $page_id=$_REQUEST['page_id'];
if(isset($page_id))
{
echo "Creating new page for page_id $page_id";
$page=new Page($page_id);
}
class Page
{
function __construct($parm)
{
if(is_numeric($parm))
{
$this->page_id=$parm;
}
elseif(strlen($parm)>0)
{
echo "Looking up the page with title $parm";
$this->title=$parm;
$this->lookup_title();
}
else
{
$this->makenew();
}
}
}feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: :arrow: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]