noob needs help
Moderator: General Moderators
-
Faster The Chase
- Forum Newbie
- Posts: 4
- Joined: Sun Jul 24, 2005 1:26 pm
noob needs help
ok im a complete php n00b and have only been programming a few weeks and im slowly getting the hang of it. atm im trying to modify a form mailer which currently has things like if
field=="";
print "you suck";
but anyway i have been changing the print bit to display some html code with some variables such as error type and admin contacts in etc. but my problem is ordering. i made the page body with some variables in such as $error_type and was expecting to add a $error_type and a print $messagebody in at each possible error but it works fine expect for i didnt realise that the type variable is called from ABOVE the message so how could i make the message change each time as easily as possible.
also some other n00b questions the book didnt cover...
what is the difference between echo and print?
and what is the difference between 'single' and "double" quotes
Cheers
field=="";
print "you suck";
but anyway i have been changing the print bit to display some html code with some variables such as error type and admin contacts in etc. but my problem is ordering. i made the page body with some variables in such as $error_type and was expecting to add a $error_type and a print $messagebody in at each possible error but it works fine expect for i didnt realise that the type variable is called from ABOVE the message so how could i make the message change each time as easily as possible.
also some other n00b questions the book didnt cover...
what is the difference between echo and print?
and what is the difference between 'single' and "double" quotes
Cheers
-
Faster The Chase
- Forum Newbie
- Posts: 4
- Joined: Sun Jul 24, 2005 1:26 pm
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
Difference between print and echo was discussed just a few threads prior to this
viewtopic.php?t=35948
As for your other q, I don't really understand what you are getting at. Please post some code examples.
As for your other q, I don't really understand what you are getting at. Please post some code examples.
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
Difference between single and double quotes:
In single quotes variables are interpreted literally, and you can output a double quote:
In double quote variables are not interpreted literally and you also have special characters like \n for a line break, you also have to escape double quotes \" like that:
Escape sequences:
\n line feed
\r carriage return
\t horizontal tab
\\ a backslash
\" double quote
\nnn character corresponding to the octal value of nnn
\xnn a character corresponding to the hexadecimal value of nn
EDIT: For the carriage return it should be a backslash then the letter after Q, Damn your AOLbonics filter to hell
, can't we establish a way to overide this for certain users?
viewtopic.php?t=29998
In single quotes variables are interpreted literally, and you can output a double quote:
Code: Select all
$a = 10;
echo 'this is a variable "$a"'; // Will output: this is a variable "$a"Code: Select all
$a=10;
echo "this is a variable \"$a\", I also could have used 'single quotes'"; // Will output: this is a variable "10"Escape sequences:
\n line feed
\r carriage return
\t horizontal tab
\\ a backslash
\" double quote
\nnn character corresponding to the octal value of nnn
\xnn a character corresponding to the hexadecimal value of nn
EDIT: For the carriage return it should be a backslash then the letter after Q, Damn your AOLbonics filter to hell
viewtopic.php?t=29998
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
Easy-peasy... phpBB lets numbered entities through so just type this in your post:jshpro2 wrote:Damn your AOLbonics filter to hell, can't we establish a way to overide this for certain users?
viewtopic.php?t=29998
Code: Select all
This should print a letter aaarrrrrhhh rThis should print a letter aaarrrrrhhh r
You could also read (or buy) http://www.hudzilla.org/phpbook/