1

I have these two php files in the same directory:

index.php

<?php

    echo "before";

    require('Parser.php');

    echo "after";
?>

Parser.php

<?php

    /**
    * Class Parser
    */
    class Parser
    {

        private $url;

        function __construct($url)
        {
            $this->url = $url;
        }



        public function getUrl(){
            return $this->url;
        }

        public functionsetUrl($url){
            $this->url = $url;
        }

    }

?>

I need to import the Parser file because i have to use this class in my index file but i can't.

There is a problem importing this class because if i try to access index.php i can see only the first print: before.

I don't know where is the problem but is very strange, my files are so simple.

My php version is 5.6 and i'm using MAMP as web server.

Can someone help me? Thanks

1
  • Turn on errors. You probably have a Fatal Error Commented Nov 4, 2014 at 22:00

1 Answer 1

4

You have a typo in your Parser class:

 public functionsetUrl($url){

should be

 public function setUrl($url){
Sign up to request clarification or add additional context in comments.

1 Comment

This is why you use an IDE that detects these kinds of problems as you type.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.