473,671 Members | 2,290 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 1214
On 28 May 2007 11:05:05 -0700, vinnie <ce**********@g mail.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.u k :: 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.a twrote:
<?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...@g mail.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
7996
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 as a standard portable part of the core language, the LISP package, and the java.lang package, respectively. Both have big integers, although only LISP has rationals as far as I can tell. Because CL supports keyword arguments, it has a wider range...
1
14374
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 Inventory..pc in %%i -fc:\bcp\bcp.fmt -T -S CHICKYy where CHICKYy is the server bcp.fmt
2
1268
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 controls render correctly or both are incorrect but never a mixture. When they are rendered correctly the source looks like <input name="Header2:txtKeyword" type="text" id="Header2_txtKeyword" style="width:80px;" / When incorrect the source looks...
1
3922
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 the following errors from time to time. Apparently the following procedure alleviates the problems: -Reboot (clears locks on following directory)
3
3339
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 the following errors from time to time. Apparently the following procedure alleviates the problems:
4
2742
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 or don't apply. For example, the following code generates an CS0628 because CS0628 makes an incorrect assumption that "protected" applies only to inheritance: public sealed class Class { EmbeddedClass utility = new EmbeddedClass();
17
1329
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 integers)? #include <stdio.h> #include <stdlib.h> int main(void) { char *a; int *x, *y;
1
2394
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 enter dice Values:
0
8306
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 records there is an error "Incorrect syntax near '-'. Must declare the scalar variable "@UserName". I worked out in design view,code is automatically generated.Iam not able fix the error. Iam working with Visual Web Developer-2005 Express Edition
0
8390
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8911
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8667
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7428
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6222
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4222
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4402
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2808
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1806
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.