Page 1 of 1

noob needs help

Posted: Sun Jul 24, 2005 1:33 pm
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

Posted: Sun Jul 24, 2005 1:57 pm
by pilau
I'd try Google.

Posted: Sun Jul 24, 2005 1:58 pm
by Faster The Chase
i checked out google and ive got an oreilly book and i still cant figure it out

Posted: Sun Jul 24, 2005 2:56 pm
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.

Posted: Sun Jul 24, 2005 2:57 pm
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.

Posted: Sun Jul 24, 2005 3:27 pm
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

Posted: Sun Jul 24, 2005 5:56 pm
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

Posted: Sun Jul 24, 2005 8:08 pm
by timvw
You could also read (or buy) http://www.hudzilla.org/phpbook/

Posted: Sun Jul 24, 2005 8:55 pm
by josh
rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr

cool thanks :-)