Jump to content

Passing variables within functions


halm1985

Recommended Posts

Use the return keyword. Here is an example of how you could get a variable for use outside a function.

 

<?php

function createVar($value){
   $var = $value;
   return $var;
}

 

Now you could do this:

$var = createVar($value);

 

and then you have the variable $var to use outside of the function.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.