Skip to content

Commit

Permalink
Changed the PSR-0 example to a PHP code block
Browse files Browse the repository at this point in the history
  • Loading branch information
Marlinc committed Jul 19, 2012
1 parent f2fe4ca commit 2776469
Showing 1 changed file with 16 additions and 15 deletions.
31 changes: 16 additions & 15 deletions accepted/PSR-0.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,23 +42,24 @@ Example Implementation

Below is an example function to simply demonstrate how the above
proposed standards are autoloaded.
```php
<?php

<?php

function autoload($className)
{
$className = ltrim($className, '\\');
$fileName = '';
$namespace = '';
if ($lastNsPos = strripos($className, '\\')) {
$namespace = substr($className, 0, $lastNsPos);
$className = substr($className, $lastNsPos + 1);
$fileName = str_replace('\\', DIRECTORY_SEPARATOR, $namespace) . DIRECTORY_SEPARATOR;
}
$fileName .= str_replace('_', DIRECTORY_SEPARATOR, $className) . '.php';

require $fileName;
function autoload($className)
{
$className = ltrim($className, '\\');
$fileName = '';
$namespace = '';
if ($lastNsPos = strripos($className, '\\')) {
$namespace = substr($className, 0, $lastNsPos);
$className = substr($className, $lastNsPos + 1);
$fileName = str_replace('\\', DIRECTORY_SEPARATOR, $namespace) . DIRECTORY_SEPARATOR;
}
$fileName .= str_replace('_', DIRECTORY_SEPARATOR, $className) . '.php';

require $fileName;
}
```

SplClassLoader Implementation
-----------------------------
Expand Down

0 comments on commit 2776469

Please sign in to comment.