Variable
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
Write the name wrong
Two young men decided to go through the graveyard in order to shorten the road. To eliminate the fear, they followed the grave telling stories and laughing. Suddenly they heard the sound of tapping a rock with a chisel. They are silent because of fear and try to listen where the sound came. There was an old man was carving gravestones. "Hey Old man, you made us surprised, we thought a ghost. What did you do at this time of night?" Without turning to the two young men, the old man replied, "Those stupid people ... They were wrong to write my name .."
Basic PHP Programming
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 ..
Searching data within the array
The easiest way to search is to check all the array elements from the smallest index to the largest index of searchable data to be found. Example use in an array of data search is shown in the following programs:
Dim data(5) As Integer
Dim x As Integer
Randomize
For i = 0 To 5
data(i) = Rnd() * 10 + 5
Next
x = InputBox("Entry Data: ", "Input")
For j = 0 To 5
If x = data(j) Then
cek = True
Exit For
Else
cek = False
End If
Next
If cek = True Then
MsgBox ("Found")
Else
MsgBox ("Not Found")
End If
Dynamic Array
If the size or the number of array elements is not known, then the array variable can be declared as an array of dynamic arrays. Understanding the dynamic array is a list or set of data with the same data type, stored in a given index variable to distinguish each member of the array where the number of elements or the amount of data stored in the array is dynamic or changing during the program starts. To declare a dynamic array can be written with the following syntax:
Dim SetArray() as DataType
From the above syntax can be seen that the size of the array or the amount of data has not been determined. To provide input data, then the very first thing to do is change the size (resize) with syntax redim (which comes from the word redimension).
Example :
1. Dim arrName() as String
2. Redim arrName(8)
Description:
In the example above; lines used to create a dynamic array with the name arrNama, while the second row using redIm to resize the array to be 9 elements (starting from index 0 to index 8).
Weaknesses using redIm is dipanggial commands every time, all the values in the previous elements will be lost. To overcome this, create a preserve for VB add an array element without deleting the previous value.
Example:
Dim NameArray(5) as Integer
NameArray(3) = 80
Msgbox (NameArray(3)) ‘The program will display the number 80
Redim Preserve NameArray(10)
Msgbox (NameArray(3)) ‘ The program will display the same number 80...