String


A string is a series of characters. This can be specified in both single quoted and double quoted ways.

To explicitly convert a value to string, use the (string) casts and this is case-insensitive.

<?php
$int_test = 10;                          // 10
$str_test = (string)$int_test;           // convert integer to string
?>
<?php
echo 'This is a simple string';
echo "\r\n";
echo 'insert
newlines';
echo "\r\n";
echo 'specify \' (single quotation)';
echo "\r\n";
echo 'specify \\ (back slash)';
echo "\r\n";
echo 'specify \ (back slash)';
echo "\r\n";
echo 'nothing happened \r\n';
echo "\r\n";
echo 'nothing $a happened';
?>
[result]  
This is a simple string
insert
newlines
specify ' (single quotation)
specify \ (back slash)
specify \ (back slash)
nothing happened \r\n
nothing $a happened
  • Double quoted
    If the string is enclosed in double-quotes ("), PHPoC will interpret more escape sequences for special characters. The special characters below can be interpreted by double quoted string. All other instances of backslash will be treated as a literal backslash.

    Sequence Meaning
    \n linefeed (LF)
    \r carriage return (CR)
    \t horizontal tab (HT)
    \\ backslash
    \" double-quote
    \$ dollar sign
    \[0-7]{base 8} character in octal notation
    \x[0-9][A-F][a-f]{base 16} character in hexadecimal notation
<?php
echo "This is a simple string";
echo "\r\n";
echo "insert \r\n newlines";
echo "\r\n";
echo "Specify \" (Double quotation)";
?>
[result]  
This is a simple string
insert
newlines
Specify " (Double quotation)

※ PHPoC is not supporting \e, \v and \f sequences.

Also, PHPoC interpret variables in this manner.

<?php
$a = "a variable";
echo "Process $a";
?>
[result]  
Process a variable