Jump to content

[SOLVED] Function: Display...


Mr_J

Recommended Posts

Fatal error: Call to undefined function: display_value() in /usr/www/users/medbqq/jaco/sams2/load18.php on line 8

 

code:

<?php

2            $value = 100;

3            function change_value($value) {

4            global $value;

5            echo "before: $value ";

6            $value = $value * 2;

7            }

8            display_value () ;

9            echo "After: $value <br>";

10  ?>

 

 

Link to comment
Share on other sites

Perhaps you want:

 

<?php
$value = 100;
function change_value($value) {
global $value;
echo "before: $value ";
$value = $value * 2;
}
change_value () ;
echo "After: $value";
?>

 

Although this code doesn't make much sense.

 

 

 

Link to comment
Share on other sites

Perhaps you want:

 

<?php
$value = 100;
function change_value($value) {
global $value;
echo "before: $value ";
$value = $value * 2;
}
change_value () ;
echo "After: $value";
?>

 

Although this code doesn't make much sense.

 

 

Almost...

This is what I did and it works!! Thanx allot

<?php

$value = 100;

function change_value() {

global $value;

echo "Before: $value ";

$value = $value * 2;

}

change_value() ;

echo "After: $value <br>";

?>

 

Link to comment
Share on other sites

Try something like this:

 

function change_value() {
global $value;
$value = $value * 2;
}

$value = 100;
echo "before: $value ";
change_value () ;
echo "After: $value";
?>

 

It's basically same code, but makes more sense this way ;)

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.