Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fatal error: Class 'Markdown' not found #162

Closed
g-liu opened this issue Apr 22, 2014 · 2 comments
Closed

Fatal error: Class 'Markdown' not found #162

g-liu opened this issue Apr 22, 2014 · 2 comments

Comments

@g-liu
Copy link

g-liu commented Apr 22, 2014

I'm using php-markdown via require_once mode.

At the top of my index.php I have require_once 'Michelf/Markdown.inc.php';. I checked the directory and file and they're all there

I try to call something as simple as:

echo Markdown::defaultTransform("hi");

and it says

Fatal error: Class 'Markdown' not found in /var/www/path/to/index.php on line 36

What's going on?

@michelf
Copy link
Owner

michelf commented Apr 22, 2014

The Markdown class is in the Michelf namespace. So you have to write the namespace too when accessing the class by writing \Michelf\Markdown. Alternatively, you can create an alias with the use keyword to avoid having to write the namespace part all the time. For reference: http://php.net/manual/en/language.namespaces.php

Does this answer your question?

@ethaniel
Copy link

ethaniel commented May 5, 2017

In case someone else finds this. Here is an example how it should be:

require_once 'Michelf/Markdown.inc.php';
echo \Michelf\Markdown::defaultTransform("hi");

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants