Annotation of embedaddon/php/ext/standard/tests/strings/strval_basic.phpt, revision 1.1
1.1 ! misho 1: --TEST--
! 2: Test strval() function : basic functionality
! 3: --FILE--
! 4: <?php
! 5: /* Prototype : string strval ( mixed $var )
! 6: * Description: Get the string value of a variable.
! 7: * Source code: ext/standard/string.c
! 8: */
! 9:
! 10: echo "*** Testing strval() : basic variations ***\n";
! 11:
! 12: error_reporting(E_ALL ^ E_NOTICE);
! 13:
! 14: $simple_heredoc =<<<EOT
! 15: Simple HEREDOC string
! 16: EOT;
! 17:
! 18:
! 19: //array of values to iterate over
! 20: $values = array(
! 21: // Simple strings
! 22: /*1*/ "Hello World",
! 23: 'Hello World',
! 24:
! 25: // String with control chars
! 26: /*3*/ "String\nwith\ncontrol\ncharacters\r\n",
! 27:
! 28: // String with quotes
! 29: /*4*/ "String with \"quotes\"",
! 30:
! 31: //Numeric String
! 32: /*5*/ "123456",
! 33:
! 34: // Hexadecimal string
! 35: /*6*/ "0xABC",
! 36:
! 37: //Heredoc String
! 38: /*7*/ $simple_heredoc
! 39: );
! 40:
! 41: // loop through each element of the array for strval
! 42: $iterator = 1;
! 43: foreach($values as $value) {
! 44: echo "\n-- Iteration $iterator --\n";
! 45: var_dump( strval($value) );
! 46: $iterator++;
! 47: };
! 48: ?>
! 49: ===DONE===
! 50: --EXPECTF--
! 51: *** Testing strval() : basic variations ***
! 52:
! 53: -- Iteration 1 --
! 54: string(11) "Hello World"
! 55:
! 56: -- Iteration 2 --
! 57: string(11) "Hello World"
! 58:
! 59: -- Iteration 3 --
! 60: string(32) "String
! 61: with
! 62: control
! 63: characters
! 64: "
! 65:
! 66: -- Iteration 4 --
! 67: string(20) "String with "quotes""
! 68:
! 69: -- Iteration 5 --
! 70: string(6) "123456"
! 71:
! 72: -- Iteration 6 --
! 73: string(5) "0xABC"
! 74:
! 75: -- Iteration 7 --
! 76: string(21) "Simple HEREDOC string"
! 77: ===DONE===
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>