Concept related to PHP strings

String variables are used for values that contains characters.

In this chapter we are going to look at the most common functions and operators used to manipulate strings in PHP.

After we create a string we can manipulate it. A string can be used directly in a function or it can be stored in a variable.

Below, the PHP script assigns the text "Hello World" to a string variable called $txt:


  • Chapter?


    $arr = array(104, 101, 108, 108, 111, 32, 119, 111, 114, 108, 100);
    $txt = "";

    for($i=0; $i < count($arr); $i++) {
    $txt .= chr($arr{$i});

    settype($txt, "string");
    echo $txt . (strcmp($txt, "hello world") == 0 ? " is a string" : " is not a string");

    Not quite C/C++, but it's something. :P

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


In this Discussion