• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 164
  • Last Modified:

how to use use a function call in a php file ?

Hello,

In my php file test.php, there are two places which used exactly the same block of code. Is that possible that I can change that block of code into a functionin in test.php. I can call this function when I need to use it ? A sample example will be very helpful. :)

Thanks very much for your reply,
lilyyan
0
lilyyan
Asked:
lilyyan
1 Solution
 
glcumminsCommented:
PHP functions are very simple to use. Here is an example:

<?php

$sum1 = addNumbers(1, 3);

$sum2 = addNumbers(5, 7);

function addNumbers($value1, $value2)
{
   return $value1 + $value2;
}

?>
0
 
lilyyanAuthor Commented:
Hi, thanks for your pormpt reply. i will have a try now and get back soon.
0

Featured Post

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now