473,511 Members | 15,156 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

anything incorrect?

why i do not see anything but a blank page?

<?php
function somma($uno,$due)
{
$totale = $uno + $due;
return($totale);
}
$sum = somma(3,4);
$totale = $resto;
print("$resto");
print("$totale");
?>

please help me, i have a test!

May 28 '07 #1
4 1206
On 28 May 2007 11:05:05 -0700, vinnie <ce**********@gmail.comwrote:
>why i do not see anything but a blank page?

<?php
function somma($uno,$due)
{
$totale = $uno + $due;
return($totale);
}
$sum = somma(3,4);
$totale = $resto;
print("$resto");
print("$totale");
?>

please help me, i have a test!
You haven't got error_reporting turned up high enough. Set it to E_ALL to see
the warnings your code produces.

--
Andy Hassall :: an**@andyh.co.uk :: http://www.andyh.co.uk
http://www.andyhsoftware.co.uk/space :: disk and FTP usage analysis tool
May 28 '07 #2
<?php
function somma($uno,$due)
{
$totale = $uno + $due;
return($totale);
}
$sum = somma(3,4);
print("$sum");
?>

You mean like this?

vinnie schrieb:
why i do not see anything but a blank page?

<?php
function somma($uno,$due)
{
$totale = $uno + $due;
return($totale);
}
$sum = somma(3,4);
$totale = $resto;
print("$resto");
print("$totale");
?>

please help me, i have a test!
May 28 '07 #3
On May 28, 2:13 pm, Philipp Grassl <p.gra...@gmx.atwrote:
<?php
function somma($uno,$due)
{
$totale = $uno + $due;
return($totale);}

$sum = somma(3,4);
print("$sum");
?>

You mean like this?

vinnie schrieb:
why i do not see anything but a blank page?
<?php
function somma($uno,$due)
{
$totale = $uno + $due;
return($totale);
}
$sum = somma(3,4);
$totale = $resto;
print("$resto");
print("$totale");
?>
please help me, i have a test!
exactly, thanks a lot!!!!

May 28 '07 #4
On May 28, 1:05 pm, vinnie <centro.ga...@gmail.comwrote:
why i do not see anything but a blank page?

<?php
function somma($uno,$due)
{
$totale = $uno + $due;
return($totale);
}
$sum = somma(3,4);
$totale = $resto;
print("$resto");
print("$totale");
?>
First things first: use a code formatting style that is easier to
read. Visit http://en.wikipedia.org/wiki/Prettyprint to learn more.

<code>
// I like C-style
<h4>Test of somma function</h4>
<p>
<?php

function somma($uno,$due) {
$totale = $uno + $due;
return $totale;
}

$sum = somma(3,4);
$totale = $sum; // Here, this was $resto, which is not pre-assigned a
value
print($resto); // Before, printed nothing, since $resto did not point
to anything
print($totale); // Before, a pointer to nothing ($resto)

?>
</p>
</code>

The error may be a scoping issue, an error in naming a variable, or
both. However, php is doing what is expected.

Since $totale is in a function where it is assigned a value, it is
considered "in the scope of the function" and is not available to the
global-space variable declaration. To make it accessible, you have to
import the global $variable:

<code>
function somma($uno,$due) {
global $totale;
// continue code with $totale available
}
</code>

You can also pass by reference:

<code>
function somma($uno, $due, &$totale) { // <-- Notice ampersand (&)
$totale = $uno + $due;
return($totale);
}
</code>

But then, somewhat inexplicably, you assign $totale to a non-declared
$sum variable (which will make $totale === null), and then try to
print both.

Note how I put a page title and a horizontal rule (<hr />) tag before
and after the code I expect to output for testing. This tells me if
the page died on parse (one kind of error, like not escaping a
sequence correctly), if the page died on processing (like calling a
function that doesn't exist), or if, in this case, the code has
nothing to output. This helps troubleshoot the code more efficiently
and effectively.

May 28 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

73
7904
by: RobertMaas | last post by:
After many years of using LISP, I'm taking a class in Java and finding the two roughly comparable in some ways and very different in other ways. Each has a decent size library of useful utilities...
1
14344
by: Michelle Hillard | last post by:
Hi guys, would appreciate if you can shed some light on this. Sorry to be a pain, can you tell me what is wrong with the following: for /F %%i in ('dir /b /on c:\bcp\pc*.txt') do bcp...
2
1264
by: Linda Wienholt | last post by:
I have two usercontrols on the home page of my website. They are intermitently sending incorrect HTML to the browser, which results in a textbox being rendered with the wrong width. Either both...
1
3915
by: murphy | last post by:
Hi, I've been seeing two symptoms with my asp.net site that have started recently after a long period of smooth running. As others on our team make changes to referenced dll's I find that I get...
3
3326
by: murphy | last post by:
Hi, I've been seeing two symptoms with my asp.net site that have started recently after a long period of smooth running. As others on our team make changes to referenced dll's I find that I...
4
2730
by: Peter Ritchie | last post by:
Does anyone know how to suppress a specific warning for a line or block of code in C#? C++ has a nice facility to disable a warning for a block of code with #pragma for warnings that are incorrect...
17
1311
by: Sourcerer | last post by:
Does any of the following constitute undefined behavior? Once I allocate memory, can I do with it whatever I want (as in the example, use memory allocated as char *, as memory where I store...
1
2376
by: ndawg123 | last post by:
Hey guys what im trying to do is write a yatzee game with C. And im stuck already and its the start?!?! I want the user to type there 5 numbers. i.e My program so far does this Please...
0
8291
by: roamnet | last post by:
hi i created database file with .mdf extention ,sql server as a source and use grid view to display data there're no problem in data retrieve and display,but i want to edit it or insert new...
0
7148
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7367
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7430
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7089
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7517
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
5072
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4743
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3217
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
790
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.