Incorrect PHP Shirt?

I've never had any PHP, but I know with C++ and Java, you can use \n within the quotes and it'll just skip to the next line. Perhaps it's similar to that?
 
No it wont output "I code $a"
(may not be using correct terms as I am just learning this also)
$a='php'; This is you setting the variable $a to equal php

The next line is retrieving the information that $a is php there for it writes in php... It displays "I code PHP"
 
no, that would be fine, you have already defined the variable above as PHP, the $sign gives the signal that it is now looking to print out the variable and not just continue prinint that block of text.

the result would be 'I code PHP'

dragon
 
Trizoy said:
No it wont output "I code $a"
(may not be using correct terms as I am just learning this also)
$a='php'; This is you setting the variable $a to equal php

The next line is retrieving the information that $a is php there for it writes in php... It displays "I code PHP"

What if you want it to output "I code $a" or $50 or $100 for that matter?
 
and if you want to output i have $a the you puy:
echo 'I have $a2;

php is an annoyign language at times, in the past few days i could have killed the inventor as nothing i did would work, even examples from php.net, they just wouldn't work on any server whatsoever

Lee :D
 
duane534 said:
That's stupid.
no its nto, it makes perfect sense....

lets break it down a bit.....

this bit $a='$100'; this is where you define the variable, the variable is any string, the string is stored in single quotes. that can be anything, any ASCII characters whatsoever, as long as its inside those single quotes it is defined as the variable.

next bit, echo "I have $a"; in the echo command, you put what you want echoed (or printed/displayed) in double quotes. so as follows, you have the normal text I HAVE then you use the dollar sign to tell the browser that its now looking for a variable to print out.... the variable is called a, it finds a and adds it in.

OUTPUT = I HAVE $100

simple

dragon
 
lee101 said:
and if you want to output i have $a the you puy:
Code:
echo 'I have $a2;

php is an annoyign language at times, in the past few days i could have killed the inventor as nothing i did would work, even examples from php.net, they just wouldn't work on any server whatsoever

Lee :D

No, that would give you an error.
 
works fine for me:
variables.jpg


Lee :D
 
lee101 said:
oh yeh, didn't see that :o

haha. Besides, you didnt use the code he posted. You left out the 2. Anyway, that script was bloated. Could of done it in 3 or less lines. Another thing. Dream Weaver? Eww. EditPlus2 or Vi for the win.
 
Smoko said:
haha. Besides, you didnt use the code he posted. You left out the 2. Anyway, that script was bloated. Could of done it in 3 or less lines. Another thing. Dream Weaver? Eww. EditPlus2 or Vi for the win.
ok then, so it would be
PHP:
<?php
echo 'I have $a2';
?>
and whats wrong with dreamweaver? i have tried alternatives but have found it the best and easiest for web design, also whats so bloated?? the code was in 3 lines, it was all the html stuff that made it so big, and i just opened dreamweaver to quickly show that eg.

Lee
 
lee101 said:
whats wrong with dreamweaver? i have tried alternatives but have found it the best and easiest for web design,

Dream Weaver == Expensive, Bloated, and Slow.

also whats so bloated?? the code was in 3 lines, it was all the html stuff that made it so big, and i just opened dreamweaver to quickly show that eg.

The code was bloated from the un-needed HTML. Could of done it faster with notepad.
 
Just for the record, DreamWeaver is industry standard, and DreamWeaver 8 is the newest and best version so far.... and lee, althought that code there IS going to echo what you put in the single quotes, you havent difined the variable, so actually your example would be 4 lines long if it was done properly...

dragon
 
Back
Top