noob needs help

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Faster The Chase
Forum Newbie
Posts: 4
Joined: Sun Jul 24, 2005 1:26 pm

noob needs help

Post by Faster The Chase »

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
pilau
Forum Regular
Posts: 594
Joined: Sat Jul 09, 2005 10:22 am
Location: Israel

Post by pilau »

I'd try Google.
Faster The Chase
Forum Newbie
Posts: 4
Joined: Sun Jul 24, 2005 1:26 pm

Post by Faster The Chase »

i checked out google and ive got an oreilly book and i still cant figure it out
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

Difference between print and echo was discussed just a few threads prior to this :?
:arrow: viewtopic.php?t=35948

As for your other q, I don't really understand what you are getting at. Please post some code examples.
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

pilau wrote:I'd try Google.
Lets try and avoid these kinds of posts -- unless you provide a link with the actual search you did, or even search terms.
josh
DevNet Master
Posts: 4872
Joined: Wed Feb 11, 2004 3:23 pm
Location: Palm beach, Florida

Post by josh »

Difference between single and double quotes:

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"
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:

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 :-), can't we establish a way to overide this for certain users?



viewtopic.php?t=29998
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

jshpro2 wrote:Damn your AOLbonics filter to hell :-), can't we establish a way to overide this for certain users?



viewtopic.php?t=29998
Easy-peasy... phpBB lets numbered entities through so just type this in your post:

Code: Select all

This should print a letter aaarrrrrhhh  r
Test:

This should print a letter aaarrrrrhhh r
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

You could also read (or buy) http://www.hudzilla.org/phpbook/
josh
DevNet Master
Posts: 4872
Joined: Wed Feb 11, 2004 3:23 pm
Location: Palm beach, Florida

Post by josh »

rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr

cool thanks :-)
Post Reply