• You are not logged in. | Login

Post a reply

November 17, 2006 3:38 am

bobbee
Member
Ranks

running the same code over and over

Hi! Thaks for the help on my other issue, now I've got another question.

Is there a way to run the same lines of code over and over without typing it or copying / pasting it over and over on my page?


 

 

November 17, 2006 6:45 pm

phppat
Member
Ranks

Re: running the same code over and over

What you're looking for is called a function.

ex.

function my_function ( $var1, $var2 ) {
  $sum = $var1 + $var2;

  return ($sum)
};

You can call it like this:

$a = 5;
$b = 10;

$the_sum = my_function ($a, $b) ## The sum = 15

PHP monster

 

 
  • Actions
  • Top
ITCrimea. Ukraine Web Development Company. Professional Developers and Web Designers Team
Custom Web Designs, Internet Applications, E-Commerce Websites, Interactive Sites, Database-Driven Sites and Services