lifeclot // say all that you can. . .

Wordpress Likes Code Examples Not (Updated)

Thursday, March 25, 2010Miscellaneous

I’ve got to modify this beast to somehow make PHP and other code snippets look nice. And preserve indentation.

Example:


<?php

class ExtendedException extends Exception {
    public function 
__construct($message "Undefined exception"$code 0xFF) {
        
parent::__construct($message$code);

        if (
class_exists("Log")) {
            
Log::WriteException($this);
        }
        else {
            throw new 
UnhandledException($message$code);
        }
    }
    
    public function 
toArray() {
        
print_r($this->getTrace());
    }
    
    public function 
__toString() {
        return 
get_class($this) . " '{$this->message}' in {$this->file} (ln. {$this->line})" PHP_EOL "{$this->getTraceAsString()}";
    }
}

?>

I am a sad panda. :(

Update: I got it working with the help of a plugin called Preserve Code Formatting which I then hacked up a little bit to call highlight_string() on PHP code. Woo!

Leave a Reply

You must be logged in to post a comment.