i am more into vb6 programming then net and the if statement in vb6 i wonder how can i use similar thing in php
just say in php form page
simple basic will do
Printable View
i am more into vb6 programming then net and the if statement in vb6 i wonder how can i use similar thing in php
just say in php form page
simple basic will do
if( $variable > 20 ) {
}
else{
}
those "{" means then and "}" means end
looks hard will try
lets write a program both in vb and php
vp example:
php example :Code:dim x as integer
x=0
if x = 0 then
Print "YES"
else
Print "NO"
end if
Code:$x = 0;
if ($x==0) {
echo "YES";
}
else {
echo "NO";
}
I would suggest you to look at some beginner level tutorials like in here: http://www.w3schools.com/php
After going through it, try creating some small projects of your own with the ideas that you learned. Say some simple basic application like you did in VB6. Try making PHP versions of some of those VB6 apps you have.
If you have any doubts, then get back to us and we will provide the solutions for your doubts. Without knowing the basics, it would really tough for you. PHP is easy to learn. Once you get the basics, it is easy as a pie. :)
For development, if you are using a Windows PC, you can download and install WAMPserver or XAMPP.
Good luck :wave:
Ladoo, think of it like this (it's how i got used to it from VB)
if VB you MAY put () around your IF. (wasted code but no real harm against it)
#1 IF example, in VB:
is the same asCode:IF A > B THEN
msgbox("yes")
END IF
#2 IF example in (still in VB):
in php you MUST use () around your condition.Code:IF (A > B) THEN
msgbox("yes")
END IF
and in php you replace THEN with a { symbol and END IF with a } symbol
so looking at example 2 again:
#2 IF example in VB:
#2 IF example translated to php:Code:IF (A > B) THEN
msgbox("yes")
END IF
once you get that down, the rest is easy.Code:IF (A > B) {
msgbox("yes");
}
and here it is:
instead of saying
you have to use TWO == symbols.Code:IF (A = B) THEN
do this
END IF
the reason is simple:Code:IF (A == B) {
do this
}
php is stupid.
in VB it knows that "Hey! i'm doing an IF because i saw the word IF!"
but php it says "wait, what was i doing after i read that word IF?? OH! TWO == symbols! that means i'm doing an IF still!"
vb vs php:
Code:
VB | PHP
----------------------------------------------
IF ( condition ) THEN | IF (condition) {
ELSE | } ELSE {
END IF | }
IF ( A > B) THEN | IF (A > B) {
IF ( A < B) THEN | IF (A < B) {
IF ( A => B) THEN | IF (A >= B){...... (ALWAYS the > or < comes before the =
IF ( A NOT B) THEN | IF (A != B) {
IF ( A <> B) THEN | IF (A != B) {
IF ( A = B) THEN | IF (A == B) {
IF (A <> B AND C = D) THEN | IF ((A != B) AND (C == D)) {
VB:
IF ( Cow > Moon AND Time = NIGHT) THEN
Print "Cow Jumped Over The Moon At Night"
ELSE
Print "Something didn't go as planned and the cow got hurt"
END IF
PHP:
IF ( (Cow > Moon) AND (Time == NIGHT)) {
echo "Cow Jumped Over The Moon At Night";
} ELSE {
echo "Something didn't go as planned and the cow got hurt";
}
Now there are 3 things that still get me. they just take getting used to.
First, VB is smart. It knows when it's done with a command.
but after every PHP command you need to type that annoying semicolon. ;
because, like i said, php just isn't that bright.
Second: the == gets me very often.
in PHP if you put one = instead of == then it will say IF ... OH, this = that so i must do { this }
so many times i stared at a php IF THEN and simply couldn't see that i had one = instead of two == causing all of my problems.
and last, remember the variable names are case sensitive.
$Hello = "Hi"
$hello = "bye"
echo "i said $Hello then i said $hello.";
output is:
i said Hi then i said bye.