< Language Tutorials

m (somewhat clearer)
(category and some other stuff)
 
(One intermediate revision by one other user not shown)
Line 1: Line 1:
{{stub}}Functions in PHP are like the [[Custom Blocks|custom blocks]] in Scratch.
+
{{stub|date=November 2018}}Functions in PHP are like the [[Custom Blocks|custom blocks]] in Scratch.
  
 
== Defining a Function ==
 
== Defining a Function ==
 +
This is a custom block in Scratch:
 +
<scratchblocks>
 +
define my custom block (value1) (value2)
 +
...
 +
</scratchblocks>
 +
 
This is how a function is defined in PHP:
 
This is how a function is defined in PHP:
 
<syntaxhighlight lang="php">
 
<syntaxhighlight lang="php">
 
<?php
 
<?php
     function functionName(){
+
     function myFunction($value1, $value2){
         // code...
+
         // code goes here
 
     }
 
     }
 
?>
 
?>
 
</syntaxhighlight>
 
</syntaxhighlight>
 +
 +
[[Category:PHP Tutorials]]

Latest revision as of 15:33, 4 January 2019

Document stub.png This article is a stub. It may be incomplete, unfinished, or have missing parts/sections. If the article can be expanded, please do so! There may be suggestions on its talk page. (November 2018)
Functions in PHP are like the custom blocks in Scratch.

Defining a Function

This is a custom block in Scratch:

define my custom block (value1) (value2)
...

This is how a function is defined in PHP:

<?php
    function myFunction($value1, $value2){
        // code goes here
    }
?>