Submit Your Article Forum Rules

Results 1 to 3 of 3

Thread: PHP: Can't access a function from a constructor?

  1. #1
    WebProWorld MVP wige's Avatar
    Join Date
    Jun 2006
    Posts
    2,981

    PHP: Can't access a function from a constructor?

    Hey everyone. I am in the process of writing a PHP class that will parse RSS files. However, in the class constructor, I can't seem to get the filter_vars() function to work. Any suggestions (or see anything I messed up)?

    PHP Code:
    // Create the feed using the passed url
        
    public function __construct ($in_url) {
            if (
    filter_var($in_urlFILTER_VALIDATE_URL)) {
                
    $this->feed $in_url;
                if (
    $xml simplexml_load_file($in_url)) {
                    
    $this->readFeed($xml);
                } else {
                    
    $this->status 'Unable to open file <a href="$in_url">$in_url</a>';
                }
            } else {
                
    $this->status 'Invalid URL';
            }
        } 
    The error I get is "PHP Fatal error: Call to undefined function filter_var() in /www/rss_feed.php on line 59"

    I know the filter_var method is supported, since I have an identical line in another class I have written.
    The best way to learn anything, is to question everything.
    Hidden Content

  2. #2
    WebProWorld MVP wige's Avatar
    Join Date
    Jun 2006
    Posts
    2,981

    Re: PHP: Can't access a function from a constructor?

    Never mind, I found my screwup.
    The best way to learn anything, is to question everything.
    Hidden Content

  3. #3
    WebProWorld MVP kgun's Avatar
    Join Date
    May 2005
    Location
    Norway
    Posts
    7,713

    Re: PHP: Can't access a function from a constructor?

    Good that you found the error.

    1. I think you already know this debugging function: PHP: var_dump - Manual that
    2. But do you know the PHP: Reflection - Manual API that follows with php 5? That opens for much more advanced debugging.

    See APRESS.COM : PHP 5 Objects, Patterns, and Practice : 9781590593806 chapter 5

    "Object Tools"

    for a good explanation.
    Hidden Content :: Hidden Content
    Hidden Content
    Conversations creates communities and conversions create profit.

Similar Threads

  1. Best real time use of Static Constructor in C#
    By aleserlee in forum General Tech Help
    Replies: 1
    Last Post: 01-05-2010, 02:23 PM
  2. How does a CMS Website function for SEO
    By PJS in forum Search Engine Optimization Forum
    Replies: 8
    Last Post: 07-12-2009, 12:43 AM
  3. PHP isset () function
    By kurt.santo in forum Web Programming Discussion Forum
    Replies: 2
    Last Post: 07-02-2007, 03:47 AM
  4. Constructor
    By abalfazl in forum Web Programming Discussion Forum
    Replies: 0
    Last Post: 03-28-2005, 02:35 PM
  5. Date function in Access
    By SBO in forum Database Discussion Forum
    Replies: 2
    Last Post: 11-30-2004, 07:52 PM

Posting Permissions

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