Skip to end of metadata
Go to start of metadata

Please have a look at PHP's page above, TSPHP treat strings more or less the same but there is one big difference. TSPHP does not support variables inside of double quoted strings. The following would cause an error:

Would cause a compiler error
string $s = "hello $name";

One would need to write the following to achieve the desired result:

string $s = "hello".$name;

Not yet supported

Heredoc, nowdoc and binary strings are not yet supported by TSPHP.

 

In addition, TSPHP does not support implicit castings from arrayresource, mixed and Classes and Objects to string. Thus the following statements would all cause a compiler error:

Would cause a compiler error
string $array = array();
resource $res; // this statement is ok
string $resource = $res;
mixed $mix = 1; // this statement is ok
string $mixed = $mix;
string $class = new Foo();

However, bool, int and float can be assigned to string due to defined implicit casts (see Type juggling).

string $a = true; // $a is still true
string $b = false; // $b is still false
string $c = 3; // $c is still 3
string $d = 3.0; // $d is still 3.0
  • No labels