Nedense bu kodu php echo değil. Nedenini anlamaya görünüyor olamaz.
<?php
function prob1(){
$sum1 = 0;
for($i=1; $i<11; $i++){
$sum1 = $sum1 + $i;
}
echo "Sum of numbers 1 - 10 is:". $sum1;
}
prob1();
?>
Herhangi bir fikir?
UPDATE: Here is the entire web page that it exists in.
<html>
<head><title>Lab 13</title></head>
<body>
<h1>Problem 1:</h1>
<?php
function prob1(){
$sum1 = 0;
for($i=1; $i<11; $i++){
$sum1 = $sum1 + $i;
}
echo "Sum of numbers 1 - 10 is:". $sum1;
}
prob1();
?>
<p>
A. This is a server-side program. The code is executed on a web server and the results are returned to the user as HTML.
<br />
B. You can use javascript to accomplish the same calculation. Javascript code is executed client-side; meaning the user's machine will execute the code and return the result.
<br />
C. There is no need to use PHP in a scenario like this. Calculations such as these are more efficiently executed client-side.
<br />
</p>
<h1>Problem 2</h1>
<?php
function prob2($x){
$y = 0;
if ($x<5)
{
$y = pow($x, 3) + 5*($x, 2) + 3;
}
else
{
$y = pow($x, 3) - 9*pow($x, 2) + 12;
}
echo "For X=" . $x . " Y=" + $y;
}
prob2(3);
prob2(8);
?>
<p>A. Yes, you can write the same code using javascript. In this situation, it wouldn't be necessary to use php unless you wanted to hide the calculation from the user.</p>
</body>
</html>