Mohsen

  1. php - How to use variable inside and outside class function

    In this example I will show how to use variables inside and outside class functions : php :

    روش استفاده از متغییر در داخل و خارج از کلاس : php :


    For instance , We have a file : "myclasses.php " and codes are :

    کد PHP:
    <?php
    class myclass{

    public 
    $myvar1;

    public static 
    $myvar2 ;


    function 
    myfunction(){

    $a =1+1;


    $this->myvar1 $a;

    self::$myvar2 234;

    }
    ...