• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 169
  • 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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Microsoft Exchange Server

The MCTS: Microsoft Exchange Server 2010 certification validates your skills in supporting the maintenance and administration of the Exchange servers in an enterprise environment. Learn everything you need to know with this course.

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