- Joined
- Aug 19, 2007
- Messages
- 4,941
- Solutions
- 11
- Reaction score
- 352
Simple question:
Can it be wrotten as:PHP:$x++;
PHP:$x = $x + 1;
If no how I can add ex. 2 to $x in every loop?
PHP:
$x += 2;
Simple question:
Can it be wrotten as:PHP:$x++;
PHP:$x = $x + 1;
If no how I can add ex. 2 to $x in every loop?
$x += 2;
<?php
function calculator1 ($num1,$num2)
{
return $num1+$num2;
}
echo calculator1 (1,5);
function calculator2 ($num3,$num4)
{
return $num3/$num4;
}
echo calculator2 (1,5);
function calculator3 ($num5,$num6)
{
return $num5*$num6;
}
echo calculator3 (1,5);
?>
<?
for($x = 0; $x<100; $x++) {
if($x%2)
echo $x."<br/>";
if($name == "math1")
break;
}
echo $name;
?>
That's not exactly "table", but in PHP its called "array". Also it would be good if you would declare the variable as an array:
before writing it elements.Code:$var = array();
Whats the disadvantage from Lua tables (as many people may be confused)?
In lua tables you may declare constants (ex. 1), key (ex. 2) and autokey (ex. 3)
Code:local table = {bla = "lol"} table.bla
Code:local table = {"bla" = "lol"} table["lol"]
while in php you may use only key and autokeyCode:local table = {"lol"} table[1]
Code:$var = array("lol" => "lol"); $var['lol']
also, Lua tables start with value 1, while php (whats actually standard...) with 0.Code:$var = array("lol"); $var[0]
ejj bad techer want ban???? am wrajt local table = {"asd" = "lol"} ES WRONG mast wrajt local table = {["asd"] = "lol"}
yuo mather am aposite fanyYou are the opposite of funny, so better stop with this fucking stupid posts.
<?
for($x = 1; $x<=100; $x++) {
if(($x+1)%2 != 0)
continue;
echo $x." ";
}
?>
<?
function calculator($num1, $num2, $type)
{if($type == "sum")
{
return $num1+$num2;
}
else if($type == "div")
{
return $num1/$num2;
}
else
return "Select a valid type (sum ,div)";
}
calculator($num1, $num2, $type);
echo calculator(7, 8 , "sulm");
?>
<?
for($x=1, $x<=100, $x++)
echo "the last number is ".$x."<br>";
?>
<?
function calculator($num1, $num2, add)
{
if ($num1 == 0) {
echo "You cant use 0";}
elseif ($num2 == 0) {
echo "you cant use 0";}
else {
return $num1+$num2}
}
?>
the first homework:
PHP:<? for($x=1, $x<=100, $x++) echo "the last number is ".$x."<br>"; ?>
why did u use <br />? isnt ok with <br>?
Second:
PHP:<? function calculator($num1, $num2, add) { if ($num1 == 0) { echo "You cant use 0";} elseif ($num2 == 0) { echo "you cant use 0";} else { return $num1+$num2} } ?>
didnt check them so please..tell me if they are ok
i didnt know what was ODD number :S
im waiting for part 3
<?php
for( $x = 1; $x <= 999999999999999999999999999999999; $x++ )
echo $x."<br />";
?>