Excellent Programming Tricks

Objcet Oriented Programming Essentials


  1. Steps
    1. Create a class
    2. Wrap all variable and classes inside class
    3. Create a new variable instance of class
    4. Handle variables and classes through instance of class. 
  2. Create a class
    1. class ExcellentProgrammingTricks {...}
  3. New instance of a class
    1. excellentProgrammingTricks (Camel Case) = new ExcellentProgrammingTricks (Pascal case);
  4. Extension of class
    1. class SecondClass extends ExcellentProgrammingTricks{...}
  5. Final Class
    1. Can't be extends by another class.
      1. final class ExcellentProgrammingTricks {...}
  6. PHP visibility methods on variable or functions
    1. Public
      1. Access inside the class itself or outside class by declaring the instance.
      2. Default 
      3. Accessed everywhere
    2. Protected
      1. Accessed only within the class itself or extensions of that class.
    3. Private 
      1. Access indie the class itself.
      2. Class instance not work.
  7. Static method
    1. Method can be accessed without initialize the class (instance of class)
      1. Example 1 class ExcellentProgrammingTricks {
          static function _myStaticFunction() {
           echo "Hi!";
          }
        1. ExcellentProgrammingTricks:: _myStaticFunction(); //Use directly without using new instance.
      2. Example 2- class ExcellentProgrammingTricks {
         static function register() {
           add_action( 'admin_enqueue_scripts', array( 'ExcellentProgrammingTricks', 'enqueue' ) );} //Use class name instead $this
        1. static function enqueue() {   wp_enqueue_style( 'style', plugins_url( '/assets/style.css', __FILE__ ) ); }}
  8. Function/Method
    1. Automatically run a function when instance is created.
      1. function __construct() {
          add_action( 'init', array( $this, '_my_post_name' ) );
         }
    2. General function
      1. [public|private|protected] function abc(){...}
    3. Access function
      1. $excellentProgrammingTricks->abc();

No comments:

Post a Comment


Authentic аnd Excellent

Website

HTML Template

Wordpress Theme

Database applications

OR

Application services?

Excellent Programming Tricks (EPT) || Iftekhar-IT || We develops the Web applications and the WordPress templates. || Excellent Programming Tricks (EPT)

© 2020 Blogger Theme by Iftekhar IT || Excellent Programming Tricks

Execllent Programming Tricks. Powered by Blogger.