|
-
Apr 28th, 2013, 01:47 PM
#1
Thread Starter
Banned
if statement
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
-
Apr 28th, 2013, 02:11 PM
#2
Addicted Member
Re: if statement
if( $variable > 20 ) {
}
else{
}
those "{" means then and "}" means end
-
Apr 29th, 2013, 11:47 AM
#3
Thread Starter
Banned
-
Apr 29th, 2013, 12:11 PM
#4
Addicted Member
Re: if statement
lets write a program both in vb and php
vp example:
Code:
dim x as integer
x=0
if x = 0 then
Print "YES"
else
Print "NO"
end if
php example :
Code:
$x = 0;
if ($x==0) {
echo "YES";
}
else {
echo "NO";
}
-
Apr 29th, 2013, 12:40 PM
#5
Re: if statement
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
If my post was helpful to you, then express your gratitude using Rate this Post. 
And if your problem is SOLVED, then please Mark the Thread as RESOLVED (see it in action - video)
My system: AMD FX 6100, Gigabyte Motherboard, 8 GB Crossair Vengance, Cooler Master 450W Thunder PSU, 1.4 TB HDD, 18.5" TFT(Wide), Antec V1 Cabinet
Social Group: VBForums - Developers from India
Skills: PHP, MySQL, jQuery, VB.Net, Photoshop, CodeIgniter, Bootstrap,...
-
May 9th, 2013, 09:19 AM
#6
Hyperactive Member
Re: if statement
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:
Code:
IF A > B THEN
msgbox("yes")
END IF
is the same as
#2 IF example in (still in VB):
Code:
IF (A > B) THEN
msgbox("yes")
END IF
in php you MUST use () around your condition.
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:
Code:
IF (A > B) THEN
msgbox("yes")
END IF
#2 IF example translated to php:
Code:
IF (A > B) {
msgbox("yes");
}
once you get that down, the rest is easy.
and here it is:
instead of saying
Code:
IF (A = B) THEN
do this
END IF
you have to use TWO == symbols.
Code:
IF (A == B) {
do this
}
the reason is simple:
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.
----------------------------------------------------
Missing the days of GWBasic 1.1
WaxyStudios.com
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|