Runing Text

Do not Click

Showing posts with label PHP. Show all posts
Showing posts with label PHP. Show all posts

Trim and strlen function

Posted by Andi on Wednesday, 20 January 2010 , under | komentar (0)



After studying the variables, we continued the discussion of the trim and strlen function. The second function is used to manipulate the string.
- Trim (); used to remove the spaces on the right or left a text, examples of program code is as follows:

< ? php
$text=" test trim ";
$text=trim($text);
echo $text.$text;
?>



Output:
test trimtest trim


- Strlen(); used to calculate the text length, examples of program code is as follows:

< ? php
$text1=" test trim ";
$text2=trim($text1);
$lentext1=" Text1 Length = ".strlen($text1);
$lentext1=" Text2 Length = ".strlen($text2);
echo $lentext2."
";
echo $lentext1;
?>


Output:
Text1 Length = 11
Text2 Length = 9

Variable

Posted by Andi on , under | komentar (0)



In making a program, it should not be forgotten is variable. Variable plays an important role in the process of temporary data storage. Writing variables should also be noted. In writing PHP variables are always denoted by sign ($) in front of variable names. Variable names must consist of one syllable, could also be a combination of numbers with letters, but should not be preceded by the numbers.
Example:
$ NumBook = 23;

Note:
PHP is case sensitive, which means writing small and large very influential. To facilitate the writing of program code, it's worth all the code is written in small letters.

To print the value of a variable can be done in the following ways:
$ Number = 23;
echo $ number

Basic PHP Programming

Posted by Andi on , under | komentar (0)



Rules in the PHP code, beginning with a <?php and ends with the sign ?> block PHP always flanked by a second sign. For each command will end with a sign; (semicolon). The following example PHP code.

< ? php
echo "Hello World";
? >



To try this code, we need an editor in this case the author uses the editor komodo dragons, and then type the php code. And do not forget to be stored in the folder C: \ Wamp \ www \ testphp \ and the file named hello.php and testphp.kpf project name. Next live run hello.php file via the browser as follows: http://localhost/testphp/hello.php ..

Related Post