Owner: paul
Members: 23




 
PHP Classes - 23 February, 2007
paul says
For anyone who is new to php, here is how a class works.

ok first, here is the full code, i can't be bothered to go into detail of whats going on, but i think it is pretty clear how all of this is working, just take a close look and you will see, even try the code out so get a clearer view

[code=php]
 
<?php
// first we name the class (i have named it text_stuff)
class text_stuff {
    // this function will make whatever text you choose bold
    function make_text_bold( $text ) {
        $output = "<b>" . $text . "</b>";
        return $output;
    }
    // this function will make whatever text you choose italic
    function make_text_italic( $text ) {
        $output = "<i>" . $text . "</i>";
        return $output;
    }
    // this function will make whatever text you choose underlined
    function make_text_underline( $text ) {
        $output = "<u>" . $text . "</u>";
        return $output;
    }
}
// this loads the class
$txt = new text_stuff;
// here is how you use it
echo $txt->make_text_bold( "This text will be bold" );
echo $txt->make_text_italic( "This text will be italic" );
echo $txt->make_text_underline( "This text will be underlined" );
// you can even use multiple ones by putting it inside each other
echo $txt->make_text_bold( $txt->make_text_italic( "This text will be bold and italic" ) );
// and even more 
echo $txt->make_text_bold( $txt->make_text_italic( $txt->make_text_underline( "This text will be bold and italic and underlined" ) ) );
?>
[/code]
Total Topic Karma: 1 - More by this Author
paul says
+0 Karma
If you dont understand any of it, just ask
- 23 February, 2007
Cappy says
+1 Karma
neato ^^
- 24 February, 2007
paul says
+0 Karma
lol
- 24 February, 2007
Comment:

Name: