php array

An array in php is a variable that stores a set or sequence of values. One array can have many elements, and each element can hold a single value, such as text or numbers, or another array. An array containing other arrays is known as a multidimensional array PHP supports arrays with both numerical and … Read more

fwrite() in php

int fwrite ( resource handle, string [, int length]) The third parameter, length, is the maximum number of bytes to write. If this parameter is supplied, fwrite() will write string to the file pointed to by handle until it reaches the end of string or has written length bytes, whichever comes first

fopen() in php

$fp = fopen(“$document_root/../orders/orders.txt”, ‘w’); When fopen() is called, it expects two, three, or four parameters. Usually, you use two Table of files mode of fopen() Mode Mode Name Meaning r Read Open the file for reading, beginning from the start of the file. r+ Read Open the file for reading and writing, beginning from the … Read more

exit in php

If you want to finish executing the entire PHP script, you can use exit. This approach is typically useful when you are performing error checking The call to exit stops PHP from executing the remainder of the script

php do while loop

The final loop type we describe behaves slightly differently. The general structure of a do…while statement is doexpression;while( condition ); A do…while loop differs from a while loop because the condition is tested at the end. This means that in a do…while loop, the statement or block within the loop is always executed at least … Read more

php for

In php the basic structure of a for loop is for( expression1; condition; expression2)expression3; expression1 is executed once at the start. Here, you usually set the initial value of a counter The condition expression is tested before each iteration. If the expression returns false, iteration stops. Here, you usually test the counter against a limit … Read more

while loop in php

The simplest kind of loop in PHP is the while loop. Like an if statement, it relies on a condition. The difference between a while loop and an if statement is that an if statement executes the code that follows it only once if the condition is true. A while loop executes the block repeatedly … Read more

switch in php

The switch statement works in a similar way to the if statement, but it allows the condition to take more than two values. In an if statement, the condition can be either true or false. In a switch statement, the condition can take any number of different values, as long as it evaluates to a … Read more