0 Commentarios
0 Acciones
4K Views
0 Vista previa
Buscar
Descubre nuevas personas, crear nuevas conexiones y hacer nuevos amigos
-
Please log in to like, share and comment!
-
PHP - $_SERVER$_SERVER $_SERVER is a PHP super global variable which holds information about headers, paths, and script locations. The example below shows how to use some of the elements in $_SERVER: ExampleGet your own PHP Server echo $_SERVER['PHP_SELF']; echo $_SERVER['SERVER_NAME']; echo $_SERVER['HTTP_HOST']; echo $_SERVER['HTTP_REFERER']; echo $_SERVER['HTTP_USER_AGENT']; echo...0 Commentarios 0 Acciones 4K Views 0 Vista previa
-
PHP - Concatenate StringsString Concatenation To concatenate, or combine, two strings you can use the . operator: ExampleGet your own PHP Server $x = "Hello"; $y = "World"; $z = $x . $y; echo $z; Try it Yourself » The result of the example above is HelloWorld, without a space between the two words. You can add a space character like this: Example $x = "Hello"; $y = "World"; $z =...0 Commentarios 0 Acciones 3K Views 0 Vista previa
-
PHP - Escape CharactersEscape Character To insert characters that are illegal in a string, use an escape character. An escape character is a backslash \ followed by the character you want to insert. An example of an illegal character is a double quote inside a string that is surrounded by double quotes: ExampleGet your own PHP Server $x = "We are the so-called "Vikings" from the north."; Try it...0 Commentarios 0 Acciones 4K Views 0 Vista previa
-
PHP - Modify StringsPHP has a set of built-in functions that you can use to modify strings. Upper Case ExampleGet your own PHP Server The strtoupper() function returns the string in upper case: $x = "Hello World!"; echo strtoupper($x); Try it Yourself » Lower Case Example The strtolower() function returns the string in lower case: $x = "Hello World!"; echo...0 Commentarios 0 Acciones 3K Views 0 Vista previa
-
PHP - Slicing StringsSlicing You can return a range of characters by using the substr() function. Specify the start index and the number of characters you want to return. ExampleGet your own PHP Server Start the slice at index 6 and end the slice 5 positions later: $x = "Hello World!"; echo substr($x, 6, 5); Try it Yourself » Note The first character has index 0. Slice to the...
-
PHP Access ArraysAccess Array Item To access an array item, you can refer to the index number for indexed arrays, and the key name for associative arrays. ExampleGet your own PHP Server Access an item by referring to its index number: $cars = array("Volvo", "BMW", "Toyota"); echo $cars[2]; Try it Yourself » Note: The first item has index 0. To access items from an associative...0 Commentarios 0 Acciones 4K Views 0 Vista previa
-
PHP Add Array ItemsAdd Array Item To add items to an existing array, you can use the bracket [] syntax. ExampleGet your own PHP Server Add one more item to the fruits array: $fruits = array("Apple", "Banana", "Cherry"); $fruits[] = "Orange"; Try it Yourself » Associative Arrays To add items to an associative array, or key/value array, use brackets [] for the key,...0 Commentarios 0 Acciones 4K Views 0 Vista previa
-
PHP Array FunctionsPHP Array Functions PHP has a set of built-in functions that you can use on arrays. Function Description array() Creates an array array_change_key_case() Changes all keys in an array to lowercase or uppercase array_chunk() Splits an array into chunks of arrays array_column() Returns the values from a single column in the input array array_combine() Creates...1 Commentarios 0 Acciones 4K Views 0 Vista previa
-
PHP ArraysAn array stores multiple values in one single variable: ExampleGet your own PHP Server $cars = array("Volvo", "BMW", "Toyota"); Try it Yourself » What is an Array? An array is a special variable that can hold many values under a single name, and you can access the values by referring to an index number or name. PHP Array Types In PHP, there are three types of arrays:...0 Commentarios 0 Acciones 2K Views 0 Vista previa
-
PHP Associative ArraysPHP Associative Arrays Associative arrays are arrays that use named keys that you assign to them. ExampleGet your own PHP Server $car = array("brand"=>"Ford", "model"=>"Mustang", "year"=>1964); var_dump($car); Try it Yourself » Access Associative Arrays To access an array item you can refer to the key name. Example Display the model of the car: $car =...0 Commentarios 0 Acciones 4K Views 0 Vista previa
-
PHP BreakThe break statement can be used to jump out of different kind of loops. Break in For loop The break statement can be used to jump out of a for loop. ExampleGet your own PHP Server Jump out of the loop when $x is 4: for ($x = 0; $x < 10; $x++) { if ($x == 4) { break; } echo "The number is: $x <br>"; } Try it Yourself...0 Commentarios 0 Acciones 2K Views 0 Vista previa
Resultados de la búsqueda