malinga91

Member
May 12, 2011
59
1
0
php class ekaka thiyena function ekak wenath function ekakin call kranne kohomda?
Ex:
file name : main.php

PHP:
class main{
function name1(){
// do something 
}
fucntion name2(){
// do something
}
}
------------------------------------
file name : function.php

PHP:
function doLogin(){
// Some code

name2(); // function in main.php
}
 
  • Like
Reactions: ad.hasareli

adinindu

Well-known member
  • Aug 11, 2008
    1,274
    252
    83
    නුගේගොඩ
    In functions.php
    PHP:
    require_once('main.php');
    function doLogin(){ 
    // Some code 
    
    $main = new main();
    $main->name2(); // function in main.php 
    }


    Alternatively you can do as this as well.

    in main.php
    PHP:
    class main{ 
    public static function name1(){ 
    // do something  
    } 
    public static fucntion name2(){ 
    // do something 
    } 
    }

    In function.php
    PHP:
    require_once('main.php');
    function doLogin(){ 
    // Some code 
    
    
    main::name2(); // function in main.php 
    }
     

    malinga91

    Member
    May 12, 2011
    59
    1
    0
    In functions.php
    in main.php
    PHP:
    class main{ 
    public static function name1(){ 
    // do something  
    } 
    public static fucntion name2(){ 
    // do something 
    } 
    }

    thanx brother.
    meke static kyla danne ai ? :shocked:


    class eke namin object ekak hadala karana ekada wadiyama hoda nethnam me widihata karana ekada wadiyenam hoda/pahasu classname::methodName() :D
     
    Last edited:

    malinga91

    Member
    May 12, 2011
    59
    1
    0
    Ade me umbala PHP code karanne mokeda bn ?

    Dreamweaver cs6 ehemath hodai maye hithe.. cs5 wala kalin define krapu variables ehema ctl + space drop down eke pennanwa. eclips wala wage.
    Notepad++
    Komado edit

    man nam thama learning a nisa notepad++ :D pul athal ithin $ ekak ehema missing unhama :lol:
     

    adinindu

    Well-known member
  • Aug 11, 2008
    1,274
    252
    83
    නුගේගොඩ
    thanx brother.
    meke static kyla danne ai ? :shocked:


    class eke namin object ekak hadala karana ekada wadiyama hoda nethnam me widihata karana ekada wadiyenam hoda/pahasu classname::methodName() :D

    Object ekak hadana eka hondayi, class eke functions related nam. I mean if the class is with a constructor you should/have to use Object method. The function is static, other method will be appropriate since it using less memory than object.