Accessing Markdown PHP function from within a class

I'm using the Markdown library for PHP by Michel Fortin. Setup is easy and it works great like this:

include_once "markdown.php";
$my_html = Markdown($my_text);

However, I have a class in which I want to pass stuff and 'Markdown' it, like so:

class Test
    public function showMarkdown ($text)
        return Markdown($text);

Obviously, my class is much larger than this, but this is what it boils down to. In my main script I do:

include_once "markdown.php";
$test = new Test();
echo $test->showMarkdown($text);

This returns an error, saying the function 'Markdown' is undefined. That seems obvious, because it's not within the class and I haven't used a scope operator. But when I put the include inside my class and use $this->Markdown or self::Markdown the function is still undefined. I figured that the Markdown function can't be defined inside another function.

So, how can I solve this? I need to do the include, which loads the Markdown function (and the rest of its family) but I want to be able to use it from within my classes. Thanks for your answers/ideas.


Your example code calls a free function called Markdown (which presumably is defined in markdown.php). You simply need to put the include in the same file as your Test class.

After doing this, you will still call Markdown as a free function, and not as an instance ($this->Markdown) or static (self::Markdown) method.

Need Your Help

Get intermediate points over a MKPolyline

iphone objective-c ios mkmapview

I have a MKPolyline with two points (a start and an ending point), on a MKMapView. Is there any way to get some intermediate points (or coordinates) along with the line, or to split the line in many

Drawing hierarchically Rectangle on WPF Canvas

c# wpf xaml canvas hierarchical

I'm trying to place rectangles like in the next picture

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.