function my_function($name) { // Ekhane $name hocche paramenteter. echo "My name is " . $name; } echo "<br>"; function multiple_parameter($name, $profession) { echo "My name is " . $name . " and I am a " . $profession; // Usiing multiple parameter } ?> <h1> <?php content(); ?> </h1> <!-- content() function is called --> <h2> <?php my_function("Durjoy"); ?> </h2> <!-- Passing "Durjoy" through my_function Function. Ekhane "Durjoy" hocche argument. --> <p><?php multiple_parameter("Durjoy", "student"); ?> </p> <!-- Using multiple argument. --> </body> </html>
<?php defined('MOODLE_INTERNAL') || die; // Make this always the 1st line in all CS fixtures. $a = my_function($a1); // Ok. $a = my_function($a1, $a2); // Ok. $b = my_function(&$b1); // Wrong. $b = my_function($b1, &$b2); // Wrong.
<html> <body> <?php include 'includes/header.inc.php'; function my_function() { //I know this is probably not the correct way to use this but i could not figure out how to // call my array outside of the function $myArray = array('myName' => 'Piotr Nowak', 'myColor' => 'Red', 'myMovie' => 'Twelve Monkeys', 'myBook' => 'Do Not Read', 'myWebsite' => 'eBay'); $myName = $myArray['myName']; echo "<h1>" . "{$myName}" . "</h1>"; $myCount = 0; "<ul>"; foreach ($myArray as $key) { if ($myCount < "1") { ++$myCount; } else { echo "<li>", $key, "</li>", "</br>"; } } } my_function(); include 'includes/footer.inc.php'; ?> </body> </html>
<?php function my_function($num1, $num2) { $sum = $num1 + $num2; echo $sum; } my_function(5, 10);
</p> <p class="printonly url"><b>URL for this page:</b> <?php get_page_url(); ?> </p> </div> <!--end content --> <!--sidebar --> <div id="sidebar"> <?php get_component('sidebar'); ?> <?php if (function_exists('my_function')) { echo my_function(); } else { echo $er; } ?> </div> <!--end sidebar --> <!--sidebar2 --> <div id="sidebar2"> <?php get_component('sidebar2'); ?> </div> <!--end sidebar2 -->
<!DOCTYPE html> <html> <head></head> <body> <p> <?php /** * Write a function that takes a "name" and "number" (n) * print the name (n) times */ function my_function($name, $number) { return str_repeat($name, $number); } echo my_function("Seth", 20); ?> </p> </body> </html>
<?php function my_function($arg) { print "Hejsa.\n"; print $arg . "\n"; } my_function("Hello world.");