php
-
Abstract and Interface
Abstract Class: An abstract class is a class that is declared abstract — it may or may not include abstract methods. Abstract classes cannot be instantiated, but they can be subclassed. An abstract class may have static fields and static methods. When an abstract class is subclassed, the subclass usually provides implementations for all of… Continue reading
-
Getters and Setters.
This is a short introductory tutorial on how to use “Getters” and “Setters” in PHP. “Getters” and “Setters” are object methods that allow you to control access to a certain class variables / properties. Sometimes, these functions are referred to as “mutator methods”. A “getter” allows to you to retrieve or “get” a given property.… Continue reading
-
Public, Private, Protected
Public Members Unless you specify otherwise, properties and methods of a class are public. That is to say, they may be accessed in three possible situations − From outside the class in which it is declared From within the class in which it is declared From within another class that implements the class in which… Continue reading
-
paging using php with multiple rows and cols
If you want to do paging in php with multiple rows and columns use this code… <?php $i = 1; $numcols = 6; // how many columns to display $numcolsprinted = 0; // no of columns so far $numitems = count($city_arr); // Number of Items $numrows = ceil($numitems/$numcols); // Number of Rows echo ‘ ‘;… Continue reading
-
chroot
chroot (PHP 4 >= 4.0.5, PHP 5) chroot — Change the root directory Description bool chroot ( string $directory ) Changes the root directory of the current process to directory. This function is only available if your system supports it and you’re using the CLI, CGI or Embed SAPI. Also, this function requires root privileges. Continue reading
CGI, chroot, CLI, directory, function, php, PHP 5, Php function, Privileges, process, root, root privileges, SAPI -
Paging using PHP
Try it for multiple rows and columns (Data would be printed in matrix): <?php $i = 1; $numcols = 6; // how many columns to display $numcolsprinted = 0; // no of columns so far $numitems = count($city_arr); // Number of Items $numrows = ceil($numitems/$numcols); // Number of Rows echo ‘ ‘; for ($row=1; $row… Continue reading
-
copy
copy (PHP 4, PHP 5) copy — Copies file Description bool copy ( string $source, string $dest [, resource $context] ) Makes a copy of the file source to dest. If you wish to move a file, use the rename() function. $file = ‘example.txt’; $newfile = ‘example.txt.bak’; if (!copy($file, $newfile)) { echo “failed to copy… Continue reading
-
array_reduce
array_reduce (PHP 4 >= 4.0.5, PHP 5) array_reduce — Iteratively reduce the array to a single value using a callback function Description mixed array_reduce ( array $input, callback $function [, int $initial] ) array_reduce() applies iteratively the function function to the elements of the array input, so as to reduce the array to a single… Continue reading
-
array_rand
array_rand (PHP 4, PHP 5) array_rand — Pick one or more random entries out of an array Description mixed array_rand ( array $input [, int $num_req] ) array_rand() is rather useful when you want to pick one or more random entries out of an array. It takes an input array and an optional argument num_req… Continue reading
-
array_push
array_push (PHP 4, PHP 5) array_push — Push one or more elements onto the end of array Description int array_push ( array &$array, mixed $var [, mixed $…] ) array_push() treats array as a stack, and pushes the passed variables onto the end of array. The length of array increases by the number of variables… Continue reading
-
array_pad
array_pad (PHP 4, PHP 5) array_pad — Pad array to the specified length with a value Description array array_pad ( array $input, int $pad_size, mixed $pad_value ) array_pad() returns a copy of the input padded to size specified by pad_size with value pad_value. If pad_size is positive then the array is padded on the right,… Continue reading
-
array_diff_uassoc
array_diff_uassoc (PHP 5) array_diff_uassoc — Computes the difference of arrays with additional index check which is performed by a user supplied callback function Description array array_diff_uassoc ( array $array1, array $array2 [, array $…, callback $key_compare_func] ) Compares array1 against array2 and returns the difference. Unlike array_diff() the array keys are used in the comparision.… Continue reading
-
Show data in Multiple rows and column
If you want to show your data in tabular format with multiple rows and column then try this: ” $sql = “SELECT * FROM table_name where Condition order by Field_type “;” “$res = $con->execQry($sql);” // Class to execute query… if($printSql) debug_helper($sql,$res); if($res && mysql_num_rows($res)) { while($row = mysql_fetch_assoc($res)) { $city_arr[] = ucwords(strtolower($row[‘datafield’])); } } //Now… Continue reading
-
substr : PHP
substr It will return part of a string specified by the start and length parameters. example: This will print string start from 1 (remember that starting point begains from 0) You can also provide 3 argument for substr like Prints only 4 charecter starting from 1 charecter Prints only last charecter of string… Continue reading
-
array_diff_key
array_diff_key (PHP 5 >= 5.1.0) array_diff_key — Computes the difference of arrays using keys for comparison Description array array_diff_key ( array $array1, array $array2 [, array $…] ) Compares the keys from array1 against the keys from array2 and returns the difference. This function is like array_diff() except the comparison is done on the keys… Continue reading