Welcome Guest, Not a member yet? Register   Sign In
[ask]Controller: doing other function in a function.
#1

[eluser]metaltapimenye[/eluser]
hey guys.. i need yer help here

i need to doing a function inside a function i've made..
Code:
<?php
class Example extends Controller {

  function doingA($varA,$varB){
    $varA+$varB;
  }

  function doingB(){
    :::
        #want to do function doingA, and its results as $varC
    :::

  $data['varc']=$varC;
  }

}
?>

maybe little-bit shallow.. but i got no one to ask. thx n_n
#2

[eluser]xwero[/eluser]
Each function or variable in a class can be called by using $this-> so your code would be
Code:
class Example extends Controller {

  function doingA($varA,$varB){
    $varA+$varB;
  }

  function doingB($varA,$varB){
        return $this->doingA($varA,$varB)+1;
  }

}
I don't know why you want to specify it to $varC. If you return the result of the doingB method you can use it for other purposes.
#3

[eluser]Grahack[/eluser]
Same question here, with same answers + the 'private' trick.
#4

[eluser]metaltapimenye[/eluser]
[quote author="xwero" date="1198855394"]Each function or variable in a class can be called by using $this-> so your code would be
Code:
class Example extends Controller {

  function doingA($varA,$varB){
    $varA+$varB;
  }

  function doingB($varA,$varB){
        return $this->doingA($varA,$varB)+1;
  }

}
I don't know why you want to specify it to $varC. If you return the result of the doingB method you can use it for other purposes.[/quote]

well lets say sometimes some methods oftenly not as simplier as sum $varA & $varB.. or sometimes i just want to get some $data['part'] stuff.. thx xwero, i hvn't try it yet.. but it just a kind of answer that i expected.

@Grahack: thx, but my nerves getting tense up when reading 'library' stuff..>_<




Theme © iAndrew 2016 - Forum software by © MyBB