-7

What is the difference between colon “:” and dot “.” in PHP code ?

below is code that used (:) in it

echo "Before Pention Deducations:$BeforePensionIncome<BR>";

if I use (.) Instead of (:) like the code below

echo "Before Pention Deducations.$BeforePensionIncome<BR>";

what is the difference between them?

Martin Schröder
  • 3,546
  • 5
  • 43
  • 77
Chavi
  • 1
  • 5

1 Answers1

2

In the context of your examples, they have no special meaning. They are literal characters in strings.

One will cause a : to be output. The other will cause a . to be output.

Quentin
  • 857,932
  • 118
  • 1,152
  • 1,264
  • but what is the different between them in general ?? – Chavi Jan 08 '14 at 16:53
  • 1
    There is no point in comparing them in general. Context is important in all programming. – Quentin Jan 08 '14 at 16:56
  • 2
    The difference in general? One is ASCII 0x2e the other is ASCII 0x3a: unless you provide a context for your question, you won't get a much better answer than that.... e.g. what's the difference when used in a regexp? what's the difference as PHP operators? – Mark Baker Jan 08 '14 at 16:56
  • so what's the difference between them as PHP operators?? – Chavi Jan 08 '14 at 16:59
  • @Chavi Everything. They're nothing alike and they aren't used in similar places. So go read about one and learn what it's for, then read about the other. Once you know what each one does, you won't care what the "difference" is. – Boann Jan 08 '14 at 16:59
  • @Chavi - one is a valid PHP operator (the [string concatenation operator](http://www.php.net/manual/en/language.operators.string.php)), the other is invalid as an operator on its own, but when combined with another colon it's the operator to access a static method or property (the [scope resolution operator](http://www.php.net/manual/en/language.oop5.paamayim-nekudotayim.php))... which reading the PHP docs will teach you – Mark Baker Jan 08 '14 at 17:00
  • @Mark Baker- Thank for u – Chavi Jan 08 '14 at 17:01