Follow Star

return

1 echo = return

1
2
3
4
5
6
7
8
9
<?php
function a($b, $c)
{
  $abc = $b + $c;
  return $abc; // Hier echo = return
}
echo a (10, 10);

?>

2 ohne echo - ohne return

1
2
3
4
5
6
7
8
9
10
<?php

function a ($b, $c)
{
  $abc = $b + $c;
}
echo a (5, 5);
a (5, 5);
echo  $abc;
?>  

3 echo !== return

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
  <?php

function a ($b, $c)
{
  $abc = $b + $c;
  return $abc; // if echo = Output = 55
}

//  قيمة الإرجاع إلى متغير
$abc = a (3, 2);

  // معالجة المتغير
$neueabc = $abc + 5;

echo $neueabc;

?>

4 echo !== return

1
2
3
4
5
6
7
8
9
10
11
12
13
14
<?php


function a()
{
  return 'knows1'; // echo knows1NULL knows1 knows1
}

echo gettype (a()) . '<br>';
echo a() . '<br>';
print a()

  // Output = string knows1 knows1
?>

5 type von echo = NULL && return = type

1
2
3
4
5
6
7
8
9
10
<?php

function a()
{
  return TRUE; echo FALSE; = NULL
}
echo gettype (a()) . '<br>';
echo a() . '<br>';

?>

6 return = type

1
2
3
4
5
6
7
8
9
10
<?php

function a()
{
  return 10.12;
}
echo gettype (a()) . '<br>';
echo a() . '<br>';

?>

7 return = type

1
2
3
4
5
6
7
8
9
10
<?php

function a()
{
  return 0;
}
echo gettype (a()) . '<br>';
echo a() . '<br>';

?>

8 echo x return von array

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
<?php
$t = 1;
function a()
{
  $abc = array ('A', 'B', 'C', 'D', 'F');
  return $abc;
}
echo gettype (a()) . '<br>';

$abc = a();

foreach ($abc as $b)
  if ($b !==1){ echo $t++;
               if ($b !==1){ echo "=>";
{
  echo $b . '<br>';
}}}

?>

8 echo == return

1
2
3
4
5
6
7
<?php
function a($b, $c)
{
    echo $b * $c;
}
echo a(4, 5);   // outputs '20'.
?>

9 return == echo

1
2
3
4
5
6
7
<?php
function a($b, $c)
{
    return $b * $c;
}
echo a(4, 5);   // outputs '20'.
?>

حذف الدالات return .

1
2
3
4
5
6
7
<?php
function a()
{
    return $b * $c;
}
echo a(4, 5);   // outputs '0'.
?>

حذف الدالات echo .

1
2
3
4
5
6
7
<?php
function a()
{
    echo $b * $c;
}
echo a(4, 5);   // outputs '0'.
?>

// array + return

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
<?php

function knows($a, $b){
    $all = $a + $b;
    $knows = array($all, $a, $b );
    return $knows;
}

list($a, $b, $all) = knows(1000, 200);
echo  "$a ="; // + لاقيمة لها الا التوضيح
echo  "$b +"; // = لاقيمة لها الا التوضيح
echo  $all;

  // 1200 =1000 +200
?>

// array + echo

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
<?php

function knows($a, $b){
    $all = $a + $b;
    $knows = array($all, $a, $b );
    echo $knows;
}

list($a, $b, $all) = knows(1000, 200);
echo  "$a ="; // + لاقيمة لها الا التوضيح
echo  "$b +"; // = لاقيمة لها الا التوضيح
echo  $all;

  // Array = +
?>
Control Structures      
if      
else      
elseif/else if      
Alternative syntax for control structures      
while      
do-while      
for      
foreach      
break      
continue      
switch      
declare      
return      
require      
include      
require_once      
include_once      
goto      

Tags:

Categories:

Updated:

Comments