Advertisement
firoze

All kind of function usages guide in php and javascript

Feb 22nd, 2016
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.76 KB | None | 0 0
  1. /* All kind of function usages guide in php */
  2.  
  3.  
  4. <h2>simple function</h2>
  5. <?php
  6.  
  7. function newFunction(){
  8. echo 'Hello World!';
  9. }
  10. newFunction();
  11. ?>
  12.  
  13. <br>
  14. <h2>function argument 1</h2>
  15. <?php
  16.  
  17. function newFunction2($arg){
  18. echo 'Hello '.$arg;
  19. }
  20. newFunction2('world!');
  21. ?>
  22.  
  23. <br>
  24. <h2>function argument 2</h2>
  25. <?php
  26. function newFunction3($age1,$age2,$age3){
  27. echo $age1,$age2,$age3;
  28. }
  29. newFunction3('New ','Function ','3');
  30.  
  31.  
  32. ?>
  33.  
  34. <br>
  35.  
  36. <h2>Single Return function</h2>
  37. <?php
  38. function newFunction9($age1){
  39. $age = "$age1";
  40. return $age;
  41. }
  42. $output = newFunction9('single Return');
  43.  
  44. echo $output;
  45.  
  46. ?>
  47.  
  48. <br>
  49.  
  50. <h2>Multiple Return function</h2>
  51. <?php
  52. function newFunction4($age1,$age2,$age3){
  53. $age = "$age1 $age2 $age3";
  54. return $age;
  55. }
  56. $output = newFunction4('Return ','Function ','3');
  57.  
  58. echo $output;
  59.  
  60. ?>
  61.  
  62. <br>
  63. <h2>Multiple Return array function</h2>
  64. <?php
  65. function newFunction5($age1,$age2,$age3){
  66. $age = "$age1 $age2 $age3";
  67. $info = "$age1 $age2 $age3";
  68. $data = "$age1 $age2 $age3";
  69. return array($age,$info,$data);
  70. }
  71. $output = newFunction5('Return ','Function ','3 ');
  72. echo $output[0];
  73. echo $output[1];
  74. echo $output[2];
  75.  
  76.  
  77. list($age,$info,$data) = newFunction5('Return ','Function ','3 ');
  78. echo '<br>';
  79. echo $age;
  80. echo '<br>';
  81. echo $info;
  82. echo '<br>';
  83. echo $data;
  84. echo '<br>';
  85.  
  86.  
  87. ?>
  88.  
  89. <br>
  90.  
  91.  
  92. ***************************************************************************************************************************
  93. /* Function Usage guide in javascript */
  94.  
  95. function my_Function(number1,number2){
  96. var result = number1 + number2 ;
  97. return result ;
  98. }
  99. // You can show data any where from the below
  100. alert(my_Function(400,500));
  101. confirm(my_Function(400,500));
  102. window.document.write(my_Function(400,500));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement