Quote:
Originally Posted by Dark_Siders
Can you explain more? how to use them?
about "^":
for example:
and some where they use this in ^" ^" format
I want to know what this do actually?
|
That "Short hand if-statement" is actually called "Ternary operator", but the name he provided is an excellent description for that operator. So, if you have something like this:
PHP Code:
if(boolean)
number = 5;
else
number = 10;
you can shorten it to:
PHP Code:
number = boolean ? 5 : 10;
I hope you can see relation between these two.
And for this:
PHP Code:
name[0] = '^0';
'^0' means that character is 0 (see ASCII table for more information).
So, these four are exactly the same:
PHP Code:
character = 'A';
character = 65;
character = '^65'; // Although not sure about this one
character = '^0x41';
And you can also use that in strings, so
PHP Code:
string[] = "H^0x65llo";
Which matches "Hello", because hex value of character 'e' in ASCII table is 0x65.
And ^" ^" format as you call it are escaped quotes. You must use escaped quotes if you use multiple quotes in your string, telling the compiler that quote in your string is not closing quote for your string, but rather just a quote character inside it. Example:
PHP Code:
string[] = "My name is ^"KliPPy^"";
Ingame, this will display
Code:
My name is "KliPPy"
If you used normal quotes just like:
PHP Code:
string[] = "My name is "KliPPy"";
the compiler would throw an error, because he would think that the string is equal to "My name is " and all after it is just some crap which should not be there.