It rewinds directory handle and can be used to check for changes in a directory.
Example
<?php
$dir = opendir(“/var/www/test/”);
while (($file = readdir($dir)) !== false)
echo $file . “<br />”;
rewinddir($dir);
closedir($dir);
?>
Output
index.php
..
.
It reads entry from directory handle
Example
<?php
$path = “/var/www/test/”;
if (is_dir($path)) {
if ($dir = opendir($path)) {
echo $directory = readdir($dir);
closedir($dir);
}
}
?>
Output
index.php
It opens directory handle
Example
<?php
$path = “/var/www/test/”;
if (is_dir($path)) {
if ($dir = opendir($path)) {
echo $directory = readdir($dir);
closedir($dir);
}
}
?>
Output
index.php
It returns the current working directory
Example
<?php
echo getcwd() . “<br />”;
chdir(‘../’);
echo getcwd() ;
?>
Output
/var/www/test/date
/var/www/test
It return an instance of the Directory class
Example
<?php
$dir = dir(“/var/www/test/date/”);
echo “Handle: ” . $dir->handle . “<br />”;
echo “Path: ” . $dir->path . “<br />”;
while (($val = $dir->read()) !== false) {
echo $val.”<br />”;
}
$dir->close();
?>
Output
Handle: Resource id #3
Path: /var/www/test/date/
index.php
enc.php
..
.
It closes directory handle
Example
<?php
$path = “/var/www/test/”;
if (is_dir($path)) {
if ($dir = opendir($path)) {
echo $directory = readdir($dir);
closedir($dir);
}
}
?>
Output
index.php
It can be used to change the root directory
Example
<?php
chroot(“YOUR-CHROOT-PATH”);
echo getcwd();
?>
Output
/
It can be used to change directory
Example
<?php
echo getcwd() . “<br />”;
chdir(‘../’);
echo getcwd() ;
?>
Output
/var/www/test/date
/var/www/test
- addcslashes – It returns a string with backslashes in front of the specified characters
- addslashes – It returns a string with backslashes in front of the specified characters
- bin2hex – It convert binary data into hexadecimal representation
- chop – Its an alias of rtrim()
- chr – It returns a character based on ASCII value
- chunk_split – It splits a string into smaller chunks
- convert_cyr_string – It converts from one Cyrillic character set to another
- convert_uudecode – It decodes a uuencoded string
- convert_uuencode – It Uuencode a string
- count_chars – It return information about characters used in a string
- crc32 – It calculates a 32-bit CRC for a string
- crypt – It returns a string encrypted using DES, Blowfish, or MD5 algorithms.
- echo() – It outputs one or more strings
- explode – It splits a string by string
- fprintf – It writes a formatted string to a specified output stream
- get_html_translation_table – It returns the translation table used by htmlspecialchars() and htmlentities()
- hebrev – It converts logical Hebrew text to visual text
- hebrevc -It convert logical Hebrew text to visual text with newline conversion
- hex2bin – It decodes a hexadecimally encoded binary string
- html_entity_decode – It convert all HTML entities to their applicable characters
- htmlentities – It convert all applicable characters to HTML entities
- htmlspecialchars_decode – It convert special HTML entities back to characters
- htmlspecialchars – It convert special characters to HTML entities
- implode – It joins array elements with a string
- join – Its an alias of implode()
- lcfirst – It make a string’s first character lowercase
- levenshtein – It calculate Levenshtein distance between two strings
- localeconv – It returns numeric formatting information
- ltrim – It strips whitespace from the beginning of a string
- md5_file – It calculates the md5 hash of a given file
- md5 – It calculates the md5 hash of a string
- metaphone – It calculate the metaphone key of a string
- money_format – It formats a number as a currency string
- nl_langinfo – It returns specific local information.
- nl2br – It inserts HTML line breaks before all newlines in a string
- number_format – It format a number with grouped thousands
- ord – It return ASCII value of character
- parse_str – It parses the string into variables
- print – It outputs a string
- printf – It output a formatted string
- quoted_printable_decode – It decodes a quoted-printable string to an 8-bit ASCII string
- quoted_printable_encode – It convert a 8 bit string to a quoted-printable string
- quotemeta – It adds backslashes in front of some predefined characters in a string.
- rtrim – It strips whitespace from the end of a string
- setlocale – It sets locale information
- sha1_file – It calculates the SHA-1 hash of a file
- sha1 – It calculates the SHA-1 hash of a file
- similar_text – It calculates the similarity between two strings
- soundex – It calculates the soundex key of a string
- sprintf – It returns a formatted string
- sscanf – It parses input from a string according to a format
- str_getcsv – It parse a CSV string into an array
- str_ireplace – It replaces some characters in a string (case-insensitive)
- str_pad – It pads a string to a certain length with another string
- str_repeat – It repeats a string
- str_replace – It replace all occurrences of the search string with another string
- str_rot13 – It perform the rot13 transform on a string
- str_shuffle – It randomly shuffles a string
- str_split – It convert a string to an array
- str_word_count – It return the number of words in a string
- strcasecmp – It compares two strings (case-insensitive)
- strchr – Its an alias of strstr() and find the first occurrence of a string
- strcmp – It compares two strings
- strcoll – It compares two strings based on locale setting
- strcspn – It returns the number of characters found in a string before any part of the specified characters are found.
- strip_tags – It strips HTML and PHP tags from a string
- stripcslashes – It removes backslashes added by the addcslashes() function
- stripos – It returns the position of the first occurrence of a string inside another string
- stripslashes – It removes backslashes added by the addslashes() function.
- stristr – It find the first occurrence of a string(case insensitive)
- strlen – It find the string length
- strnatcasecmp – It compares two strings using a “natural” algorithm.
- strnatcmp – It compares two strings using a “natural” algorithm.
- strncasecmp – It compares two strings
- strncmp – It compares first n characters (case-sensitive) of a strings
- strpbrk – It searches a string for any of the specified characters.
- strpos – It finds the position of the first occurrence of a substring in a string
- strrchr – It finds the last occurrence of a character in a string
- strrev – It reverse a string
- strripos – It find the position of the last occurrence of a substring in a string(case-insensitive)
- strrpos – It finds the position of the last occurrence of a substring in a string
- strspn – It returns the number of characters found in the string that contains only characters from the charlist.
- strstr – It finds the first occurrence of a string
- strtok – It splits a string into smaller strings
- strtolower – It makes a string lowercase
- strtoupper – It makes a string uppercase
- strtr – It translate characters or replace substrings
- substr_compare – It compares two strings from a specified start position
- substr_count – It counts the number of substring occurrences
- substr_replace – It replace text within a portion of a string
- substr – It returns part of a string
- trim – It strips whitespace from the beginning and end of a string
- ucfirst – It make a string’s first character uppercase
- ucwords – It converts the first character of each word in a string to uppercase
- vfprintf – It writes a formatted string to a specified output stream
- vprintf – It output a formatted string
- vsprintf – It return a formatted string
- wordwrap – It wraps a string into new lines when it reaches a specific length.
Zend | Magento Certified PHP | eCommerce Architect