Last active
August 29, 2015 14:22
-
-
Save derpixler/69c9ad79e55093d3f056 to your computer and use it in GitHub Desktop.
The question is, is a class equal to object-oriented or procedural
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class object_class { | |
/** | |
* holds some data | |
* @var object | |
*/ | |
public static $var = 0;; | |
/** | |
* Class Constructor | |
* | |
* @author rreimann | |
* @return void | |
*/ | |
public function __construct() { | |
#Do some on class initialization | |
} | |
/** | |
* a initail function | |
* | |
* @author rreimann | |
* @return int | |
*/ | |
public function init( $param ) { | |
self::$var = $param; | |
#do some | |
return self::$var; | |
} | |
} | |
$object = new object_class(); | |
echo $object->init( 1 ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class procedural_class { | |
/** | |
* Class Constructor | |
* | |
* @author rreimann | |
* @return void | |
*/ | |
public function __construct( $param ) { | |
if( $param = 1 ){ | |
#doanything | |
}elseif( $param = 2 ){ | |
#doanything | |
}elseif( $param = 3 ){ | |
#doanything | |
}elseif( $param = 4 ){ | |
#doanything | |
}elseif( $param = 5 ){ | |
#doanything | |
}elseif( $param = 6 ){ | |
#doanything | |
}else{ | |
#doanything | |
} | |
} | |
} | |
new procedural_class(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment