Jump to content

still learning = dot operator


kenzai
 Share

Recommended Posts

im still learning PHP on w3school website and i found something im dont quite understand about the dot ( " . . " ) uses..here goes<html><body><?php$txt1="Hello World";$txt2="1234";echo $txt1 . " " . $txt2 ; // this dots start with dots first then the " ( . " " . )?></body></html>and<?php $i=1;while($i<=5) { echo "The number is " . $i . " <br /> "; // this one starts with " then dots ( " . . " ) $i++; // oh and this, i dont know what this ++ means }?>im kinda confuse here.. that doesn't work the same way the other way around?and the <br /> , shud we put that "/" ? is it neccessary, or without it the br will still work?

Link to comment
Share on other sites

$txt1="Hello World";$txt2="1234";echo $txt1 . " " . $txt2 ; // this dots start with dots first then the " ( . " " . )
Those dots are concatenators. In this example above, "Hello World 1234" would be echo'd to the screen rather than "Hello World1234" because "Hello World", " " (a space), and "1234" were all concatenated together with the dot operator.
$i++; // oh and this, i dont know what this ++ means
The ++ (and --) are unary operators that increment (or decrement) a number by one. In the example above, if $i were 5, $i would equal 6 after $i++ executed.
$i = 5;$i++echo $i; // 6 would be echo'd

and the <br /> , shud we put that "/" ? is it neccessary, or without it the br will still work?
It'll work without the / as long as you don't declare your document as html rather than xhtml. If you want more information on xhtml, check out the tutorial:http://www.w3schools.com/xhtml/default.asp
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...