PHP Basic
PHP, or Hypertext Preprocessor, is a widely-used open-source server-side scripting language designed for web development. It is embedded in HTML and is primarily used to develop dynamic web pages and applications. PHP code is executed on the server, generating HTML that is then sent to the client’s browser. It supports a wide range of databases and offers extensive functionality for tasks such as form handling, session management, and database interaction. PHP is known for its simplicity, ease of use, and flexibility, making it a popular choice for creating interactive and data-driven websites.
PHP Intro
PHP is a popular server-side scripting language designed for web development, enabling dynamic content creation and interaction with databases.
PHP Install
PHP Install refers to the process of setting up the PHP scripting language on a server or local machine to run PHP code for web development.
PHP Syntax
PHP Syntax refers to the set of rules and conventions for writing code in the PHP scripting language, including the structure and format of PHP scripts.
PHP Comments
PHP comments are non-executable annotations in the code, used to explain or clarify sections of the script, which can be single-line (// or #) or multi-line (/* ... */).
PHP multiline comments allow you to write explanations or notes that span multiple lines, using the syntax /* comment */
.
PHP Variables
Variables are named storage locations in programming that hold data values, which can be changed during the execution of a program.
Variable scope refers to the context in which a variable is defined and accessible, determining where it can be used within a program.
PHP echo / print
PHP echo and print are constructs used to display output on the screen, with echo supporting multiple arguments and being faster, while print returns 1 and can only take one argument.
PHP Data Types
PHP data types are classifications that determine the type of data a variable can hold, including string, integer, float, boolean, array, object, NULL, and resource.
PHP Strings
PHP strings are sequences of characters enclosed in quotes, which can include letters, numbers, and symbols.
Modifying strings in PHP involves changing, replacing, or altering the content of a string using various functions and methods.
Concatenating strings in PHP involves joining two or more strings together using the concatenation operator (.).
Slicing strings in PHP involves extracting a portion of a string using functions like substr().
Escape characters are special sequences in strings that allow for the inclusion of characters that would otherwise be difficult to represent, such as newline (n
), tab (t
), or a backslash itself (\
).
PHP Numbers
PHP numbers are data types that represent numerical values, including integers, floating-point numbers, and sometimes hexadecimal or binary literals.In this chapter, we will delve deeply into integers, floats, and numeric strings.
PHP Casting
Sometimes, you may need to change a variable from one data type to another, or you may want a variable to have a specific data type. This can be accomplished through casting.
PHP Math
PHP provides a set of math functions that enable you to perform mathematical operations on numbers.
PHP Constants
Constants are similar to variables, but once defined, they cannot be changed or undefined.
PHP Magic Constants
PHP Magic Constants are predefined constants that change based on their context, such as the current file name, line number, or directory path.
PHP Operators
PHP operators are symbols that perform operations on variables and values, including arithmetic, comparison, logical, and assignment operations.
PHP if...Else...Elseif
Conditional statements are used to execute different actions depending on various conditions.
PHP if Operators are used to execute code based on a condition being true.
PHP's if...else
statement allows you to execute one block of code if a condition is true and another block if it's false.
PHP shorthand if, also known as the ternary operator, allows you to write a compact conditional statement in the form condition ? value_if_true : value_if_false.
PHP Nested if allows you to place one if statement inside another to check multiple conditions in a hierarchical manner.
PHP switch
The switch statement is utilized to execute various actions depending on different conditions.
PHP Loops
Loops are programming constructs that repeatedly execute a block of code as long as a specified condition is met.In the upcoming chapters, you will discover how to reuse code using loops in PHP.
The while loop iterates through a block of code as long as the specified condition remains true.
The do...while loop executes a block of code once and then continues to repeat the loop as long as the specified condition is true.
The for loop iterates through a block of code a defined number of times.
The foreach loop iterates through a block of code for each element in an array or each property in an object.
The break statement can be used to exit various types of loops.
The continue statement can be used to skip the current iteration of a loop and proceed to the next one.
PHP Functions
The true strength of PHP lies in its functions.It offers over 1,000 built-in functions, and you can also create your own custom functions.
PHP Arrays
An array contains multiple values in a single variable.
Indexed arrays are arrays that use numeric indices to store and access their elements.
Associative arrays are arrays that use named keys to store and access their elements.
Creating arrays involves defining a collection of values stored under a single variable name.
Accessing an array item involves using its index or key to retrieve its value.
Update Array Items" refers to the process of changing the values of specific elements within an array to new values.
"Add Array Items" refers to the process of including new elements to an existing array.
"Remove Array Item" refers to the process of deleting a specific element from an existing array.
Array elements can be sorted in alphabetical or numerical order, either in ascending or descending order.
In the previous sections, we discussed arrays that consist of a single list of key/value pairs. However, sometimes you may need to store values associated with multiple keys. For this purpose, we use multidimensional arrays.
Array Functions" are built-in functions in programming languages that perform operations on arrays, such as sorting, searching, or modifying elements.
PHP Superglobals
Superglobals, introduced in PHP 4.1.0, are built-in variables that are always accessible in all scopes.
$GLOBALS is an array that holds all global variables.
$_SERVER is a PHP superglobal variable that contains information about headers, paths, and script locations.
$_REQUEST is a PHP superglobal array that contains the contents of $_GET, $_POST, and $_COOKIE, allowing access to input data from various sources in a single variable.
$_POST is a PHP superglobal array used to collect form data sent with the HTTP POST method.
$_GET
is a PHP superglobal array used to retrieve variables passed to the current script via URL parameters.
PHP RegEx
PHP Regular Expressions (Regex) are patterns used to match and manipulate strings based on specified rules and criteria.
PHP Form
PHP form handling involves processing user-submitted data from HTML forms using PHP scripts, enabling interaction and data manipulation between web users and servers.
PHP form validation ensures that user-submitted data meets specified criteria (e.g., required fields, correct format) to prevent errors and enhance security in web applications.
PHP Forms - Required fields ensure necessary user input for form submission and processing.
PHP Forms URL/E-mail validation ensures inputted data conforms to proper URL and email address formats for accuracy and security.
Complete: Fully finished with all necessary parts or steps included.
PHP Advanced
In PHP, you can get the current date and time with one line of code using the date
function:
The include (or require) statement incorporates the entire content, whether it's text, code, or markup, from a specified file into the file that invokes the statement.
File handling is a crucial aspect of any web application. You frequently need to open and process files for various tasks.
In PHP, file operations like opening and reading are managed using functions such as fopen()
and fread()
.
PHP's file create/write functions, such as fopen()
with the 'w' mode, allow you to create a new file or open an existing one for writing, and fwrite()
lets you write data to that file.
PHP file upload allows users to upload files from their local system to the server using an HTML form and PHP's $_FILES
superglobal.
PHP cookies are used to store data on the client-side, allowing the server to retrieve and use this data across multiple requests.
PHP sessions allow you to store user information on the server for use across multiple pages of a website, maintaining state and user data persistently during a user's visit.
Validating data means checking if the data is in the correct format.
Sanitizing data involves removing any illegal characters from the data.
PHP filters advanced allow for complex validation and sanitization of data using custom options and flags to ensure precise control over data processing.
PHP callback functions are user-defined functions passed as arguments to other functions or methods, allowing for custom processing and extension of functionality.
PHP and JSON interact to allow PHP scripts to encode and decode JSON data for easy data exchange and manipulation.
PHP exceptions are used to handle errors and exceptional conditions in a program by providing a mechanism to catch and manage these issues gracefully.
PHP OOP
Starting from PHP 5, you can also write PHP code using an object-oriented style.
Object-oriented programming is more efficient and easier to manage.
In PHP OOP, classes define the structure and behavior of objects, while objects are instances of these classes that encapsulate data and functionality.
In PHP, the __construct
function is a special method called when a new instance of a class is created, allowing for initial setup or configuration of the object.
In PHP OOP, a destructor is a special method, __destruct()
, called automatically when an object is destroyed or goes out of scope, allowing for cleanup operations.
In PHP, access modifiers control the visibility of class properties and methods, with public
, protected
, and private
defining their accessibility levels.
In PHP OOP, inheritance allows a class (subclass) to inherit properties and methods from another class (parent class), promoting code reuse and extension.
In PHP, class constants are fixed values defined within a class using the const
keyword, which cannot be changed once set and are accessed using the class name.
In PHP OOP, an abstract class is a class that cannot be instantiated directly and is used as a base for other classes, often containing abstract methods that must be implemented by subclasses.
Traits are a mechanism for code reuse in single inheritance languages like PHP, allowing the inclusion of methods in multiple classes without using inheritance.
Static methods in PHP belong to a class rather than an instance of the class and can be called directly using the class name.
Static properties are class variables shared among all instances of a class and can be accessed without creating an instance.
Namespaces in PHP provide a way to encapsulate and organize code, preventing name conflicts and allowing for better code management.
In PHP, iterables are any values that can be looped over using a foreach
loop, such as arrays and objects implementing the Traversable
interface.
MySQL Database
With PHP, you can connect to and manipulate databases. MySQL is the most widely used database system in conjunction with PHP.
In MySQL, mysqli_connect()
establishes a connection to a MySQL database server.
The CREATE DATABASE
statement in MySQL is used to create a new database.
The CREATE TABLE
statement in MySQL is used to create a new table within a database.
The INSERT INTO
statement in MySQL is used to add new records to a table.
To get the last inserted ID, you use the LAST_INSERT_ID()
function or method provided by the MySQLi or PDO library.
The INSERT INTO
statement in MySQL can also be used to insert multiple rows of data in a single query.
In MySQL, a prepared statement is a feature used to execute SQL queries efficiently and securely.
The SELECT
statement in MySQL is used to retrieve data from one or more tables in a database.
The WHERE
clause in MySQL filters records to retrieve only those that meet specified conditions.
The ORDER BY
clause in MySQL sorts the result set based on one or more columns.
The DELETE
statement in MySQL removes one or more rows from a table based on a specified condition.
The UPDATE
statement in MySQL modifies existing records in a table based on specified conditions.
The LIMIT
clause in MySQL restricts the number of rows returned by a query.
PHP XML
PHP XML parsers are tools used to read, manipulate, and process XML data in PHP scripts.
The PHP SimpleXML parser provides a straightforward way to read and manipulate XML data as objects.
PHP SimpleXML's get
functionality retrieves node values from an XML document.
PHP XML Expat is an event-driven parser that processes XML data by triggering events as it encounters various XML elements.
The built-in DOM parser enables XML document processing in PHP.
PHP Reference
Define an array in PHP using the array()
function or the short array syntax []
.
The array()
function in PHP is used to create an array.
Define a multidimensional array:
The array_chunk() function splits an array into chunks of a specified size.
The array_column() function retrieves values from a specific column in a multidimensional array.
The array_combine()
function creates an array by using one array for keys and another for its values.
The array_count_values()
function counts the occurrences of each value in an array and returns an associative array.
The array_diff()
function compares arrays and returns the values from the first array that are not present in the other arrays.
The array_diff_assoc()
function compares arrays and returns the differences, including both values and keys.
The array_diff_key() function compares arrays and returns the differences based on the keys only.
The array_diff_uassoc()
function compares arrays based on both keys and values using a user-defined callback function, returning the differences.
Compare the keys and values of three arrays using a user-defined function to compare the keys, and return the differences.
The array_fill() function fills an array with a specified value, starting at a given index and for a specified length.
The array_fill_keys()
function creates an array with specified keys, all assigned the same value.
The array_filter() function filters elements of an array using a callback function.
The array_flip() function exchanges all keys and values in an array.
The array_intersect() function returns an array containing all the values that are present in all of the given arrays.
The array_intersect_assoc()
function returns an array containing values and keys that are present in all of the given arrays.
The array_intersect_key()
function returns an array containing all the entries from the first array that have matching keys in all other arrays.
The array_intersect_uassoc()
function compares arrays and returns the matches, using a user-defined callback function to compare the keys and values.
The array_intersect_ukey() function compares the keys of two or more arrays using a user-defined function, and returns the matching entries.
The array_key_exists() function checks if a given key exists in an array.
The array_keys() function in PHP returns all the keys or a subset of the keys of an array.
The array_map() function applies a callback to each element of one or more arrays and returns an array with the modified elements.
The array_merge() function combines the elements of two or more arrays into one array.
The array_merge_recursive() function merges one or more arrays into one array, recursively combining values with the same keys.
The array_multisort() function sorts multiple or multidimensional arrays simultaneously.
The array_pad() function returns a new array with a specified number of elements, padding the original array with a given value.
The array_pop() function removes and returns the last element from an array.
The array_product() function calculates and returns the product of all the values in an array.
The array_push() function adds one or more elements to the end of an array.
The array_rand() function selects one or more random keys from an array.
The array_reduce()
function iteratively reduces an array to a single value using a callback function.
array_replace() is a PHP function that replaces the values of the first array with the values from subsequent arrays based on matching keys.
array_replace_recursive() is a PHP function that recursively replaces values in the first array with values from subsequent arrays based on matching keys.
array_reverse() is a PHP function that returns an array with its elements in reverse order.
array_search() is a PHP function that searches for a value in an array and returns the corresponding key if the value is found.
array_shift() is a PHP function that removes the first element from an array and returns it, shifting all other elements down by one position.
array_slice() is a PHP function that extracts a portion of an array, returning a new array containing the specified elements.
array_splice() is a PHP function that removes and/or replaces elements from an array, and optionally inserts new elements at a specified position.
array_sum()
is a PHP function that calculates and returns the sum of all values in an array.
The array_udiff()
function in PHP compares array values using a user-defined callback function and returns the differences between the arrays.
The array_udiff_assoc() function in PHP compares the values and keys of two or more arrays using a user-defined callback function and returns the differences.
The array_udiff_uassoc() function in PHP compares the values and keys of two or more arrays using user-defined callback functions for both values and keys and returns the differences.
The array_uintersect()
function in PHP compares the values of two or more arrays using a user-defined callback function and returns the common values.
The array_uintersect_assoc() function compares both the keys and values of two or more arrays using user-defined functions and returns the entries that are present in all of the arrays.
The array_uintersect_uassoc() function in PHP compares both the keys and values of two or more arrays using user-defined callback functions for both, and returns the common entries.
The array_unique() function in PHP removes duplicate values from an array and returns an array with only unique values.
The array_unshift() function in PHP adds one or more elements to the beginning of an array and returns the new number of elements in the array.
The array_values() function in PHP returns all the values from an array and indexes them numerically.
The array_walk() function in PHP applies a user-defined callback function to each element of an array.
The array_walk_recursive() function in PHP applies a user-defined callback function to each element of a multidimensional array.
The arsort()
function in PHP sorts an array in descending order while maintaining the association between keys and values.
The asort()
function in PHP sorts an associative array in ascending order by value while maintaining key-value associations.
The compact()
function in PHP creates an array from variables and their values.
The count()
function in PHP returns the number of elements in an array or properties of an object.
The current()
function in PHP returns the current element of an array.
The each()
function returns the current key and value pair from an array and advances the internal pointer forward.
The end()
function moves the internal pointer to the last element of an array and returns its value.
The extract() function imports variables from an array into the current symbol table.
The in_array()
function checks if a value exists in an array.
The key() function returns the key of the current element in an array.
The krsort()
function sorts an associative array in descending order by key.
Sort an associative array in ascending order, according to the key.
Assign values to a list of variables in one operation.
The natcasesort()
function sorts an array using a natural order algorithm in a case-insensitive manner.
Sort an array using a natural order algorithm, keeping the original keys.
In Python, the next()
function retrieves the next item from an iterator.
In PHP, the pos() function (an alias of current()) returns the value of the current element in an array.
In PHP, the prev() function moves the internal pointer to the previous element in the array and returns its value.
In PHP, the range()
function creates an array containing a range of elements, from a specified start value to an end value.
In PHP, the reset() function moves the internal pointer of an array to the first element and returns its value.
In PHP, the rsort() function sorts an array in reverse order.
In PHP, the shuffle() function randomly rearranges the elements of an array.
In PHP, the sizeof()
function returns the number of elements in an array or the length of a countable object.
The sort()
function arranges the elements of an array in ascending order.
In PHP, the uasort() function sorts an array by values using a user-defined comparison function, while maintaining the original keys.
In PHP, the uksort() function sorts an array by its keys using a user-defined comparison function, preserving the key-value associations.
In PHP, the usort() function sorts an array by its values using a user-defined comparison function and does not preserve key-value associations.
PHP's Calendar extension provides functions for working with dates and times, including operations for various calendar systems and date formatting.
The cal_days_in_month() function returns the number of days in a specified month of a given calendar.
The cal_from_jd()
function converts a Julian Day Count to a date in a specified calendar system.
The cal_info() function returns an array containing information about a specified calendar.
The cal_to_jd() function converts a date from a specified calendar to a Julian Day Count.
To define a one-liner function for calculating the date of Easter in Python.
To define a one-liner function for calculating the number of days until Easter in Python.
The frenchtojd() function converts a French Republican calendar date to a Julian Day Count.
The gregoriantojd() function converts a Gregorian calendar date to a Julian Day Count.
The jddayofweek() function returns the day of the week for a given Julian Day Number.
The jdmonthname() function returns the name of a specified month for a given Julian Day Number.
The jdtofrench() function converts a Julian Day Number to a French Republican calendar date.
The jdtogregorian() function converts a Julian Day Number to a Gregorian calendar date.
The jdtojewish() function converts a Julian Day Number to a Jewish calendar date.
The jdtojulian() function converts a Julian Day Number to a Julian calendar date.
The jdtounix() function converts a Julian Day Number to a Unix timestamp.
The jewishtojd()
function converts a Jewish calendar date to a Julian Day Number.
The juliantojd()
function converts a Julian calendar date to a Julian Day Number.
The unixtojd()
function converts a Unix timestamp to a Julian Day Number.
The PHP date() function formats a Unix timestamp into a human-readable date and time string.
The checkdate() function in PHP is used to validate a Gregorian calendar date.
The date_add() function in PHP adds an interval to a given DateTime object and returns the resulting date.
The date_create_from_format() function in PHP creates a DateTime object from a specified format and string.
The date_create() function in PHP creates a new DateTime object from a specified date/time string and optional timezone.
The date_date_set() function in PHP sets the date of a DateTime object to a specified year, month, and day.
The date_default_timezone_get() function in PHP retrieves the default timezone used by all date/time functions.
The date_default_timezone_set() function in PHP sets the default timezone for all date/time functions.
The date_diff() function in PHP calculates the difference between two DateTime objects and returns a DateInterval object.
The date_format() function in PHP formats a DateTime object according to a specified format string.
Returns the formatted date as a string; FALSE on failure.
The date_interval_create_from_date_string()
function in PHP creates a DateInterval object from a date interval specification in string format.
The date_interval_format() function in PHP formats a DateInterval object according to a specified format string.
The date_isodate_set()
function in PHP sets the year, month, and day of a DateTime object using ISO 8601 format.
The date_modify() function in PHP modifies a DateTime object by adding or subtracting a specified interval.
The date_offset_get() function in PHP returns the timezone offset of a DateTime object in seconds.
The date_parse_from_format() function in PHP parses a date/time string according to a specified format and returns an associative array with date and time information.
The date_parse() function in PHP parses a date/time string and returns an associative array with detailed information about the date and time components.
The date_sub() function in PHP subtracts a specified interval from a DateTime object.
The date_sun_info()
function in PHP returns an associative array with information about sunrise, sunset, and solar noon for a given date and location.
The date_sunrise()
function in PHP returns the sunrise time for a given date and location.
The date_sunset() function in PHP returns the sunset time for a specified date and location.
The date_time_set() function sets the time for a DateTime object.
Retrieve the Unix timestamp from a DateTime object.
Set the Unix timestamp:
Returns the timezone of a DateTime object.
Sets the timezone for a DateTime object.
The date() function in PHP returns the current date and time, formatted according to the specified format string.
getdate() returns an associative array containing the date and time information of a given timestamp or the current local time if no timestamp is provided.
The gettimeofday() function returns an associative array containing the current time, including seconds, microseconds, and timezone information.
The gmmktime() function returns the Unix timestamp for a specified GMT/UTC date and time.
The gmstrftime() function formats a GMT/UTC date and time according to a specified format string.
The idate()
function returns a specific component of a Unix timestamp as an integer.
localtime(): Returns an associative array containing local time information for a given timestamp or the current local time.
The microtime() function returns the current Unix timestamp with microseconds as a string.
The mktime() function returns a Unix timestamp for a specified date and time.
The strftime()
function formats a local time/date according to locale settings.
The strptime() function parses a date/time string according to a specified format and returns an associative array with the parsed values.
The strtotime() function in PHP parses a time string and returns the equivalent Unix timestamp.
The time() function in PHP returns the current Unix timestamp (the number of seconds since January 1, 1970, 00:00:00 GMT).
The timezone_abbreviations_list() function in PHP returns an array of all timezone abbreviations and their corresponding timezone information.
The timezone_identifiers_list() function in PHP returns an array of all supported timezone identifiers.
The timezone_location_get() function in PHP retrieves the geographical location information for a given DateTimeZone object.
The timezone_name_from_abbr() function in PHP returns the full timezone name corresponding to a given abbreviation.
The timezone_name_get() function in PHP retrieves the name of the timezone from a given DateTimeZone object.
The timezone_offset_get() function in PHP returns the timezone offset from UTC for a given DateTime object and DateTimeZone object.
The timezone_open() function in PHP creates a new DateTimeZone object for a specified timezone.
The timezone_transitions_get() function in PHP retrieves an array of transition information for a given DateTimeZone object.
The timezone_version_get() function in PHP returns the version of the timezone database currently in use.
The PHP Directory class provides methods for interacting with file system directories.
The chdir()
function in PHP changes the current working directory to the specified path.
The chroot() function changes the root directory for the current running process to a specified path.
The closedir() function in PHP closes an open directory handle.
The dir()
function in PHP creates a Directory
object for the specified path, allowing directory operations.
The getcwd() function in PHP returns the current working directory as a string.
The opendir() function in PHP opens a directory and returns a directory handle resource.
The readdir() function reads the next entry from an open directory handle.
The rewinddir() function resets the directory handle to the beginning of the directory.
The scandir() function in PHP returns an array of filenames and directory names from a specified directory.
Error functions in PHP handle error reporting, logging, and management for code execution.
The debug_backtrace() function provides an array of information about the call stack at the point where it is invoked.
The error_get_last() function in PHP retrieves the last error that occurred.
The error_log() function in PHP sends an error message to the server's error log or to a file.
The error_reporting() function in PHP sets the level of error reporting, determining which types of errors are displayed or logged.
The restore_error_handler() function in PHP restores the previous error handler.
The restore_exception_handler() function restores the previous exception handler.
The set_error_handler() function sets a user-defined function to handle errors.
The set_exception_handler() function sets a user-defined function to handle uncaught exceptions.
The trigger_error() function generates a user-level error message.
A PHP Exception is an object representing an error or exceptional condition in a script, which can be caught and handled with a try-catch block.
An Exception in PHP represents an error or exceptional condition that can be caught and handled using try-catch blocks.
The getCode() method returns the exception code associated with the Exception object.
The getFile() method returns the file path where the exception was thrown.
The getMessage() method returns the error message associated with the exception.
The getLine() method returns the line number where the exception was thrown.
The getPrevious() method retrieves the previous exception that caused the current exception.
The getPrevious()
method retrieves the previous exception that caused the current exception.
The getTraceAsString() method returns the stack trace as a formatted string.
PHP Filesystem allows for file and directory manipulation, including reading, writing, and managing files and directories.
The basename() function in PHP returns the filename from a given path, removing any leading directory components. For example, basename('/path/to/file.txt') returns 'file.txt'.
The chgrp() function in PHP changes the group ownership of a specified file or directory.
The chmod() function in PHP changes the file permissions of a specified file or directory.
The chown() function in PHP changes the owner of a specified file or directory.
clearstatcache() is a PHP function that clears the file status cache.
The copy() function in PHP duplicates a file from a source to a destination.
The delete() function in PHP removes a file or directory.
The dirname() function in PHP returns the directory path of a specified file or directory.
The disk_free_space() function in PHP returns the amount of free space available on a specified disk or directory.
The disk_total_space() function in PHP returns the total size of the specified filesystem or disk in bytes.
diskfreespace() is an older alias for the disk_free_space() function in PHP. It returns the amount of free space available on a specified disk or directory.
The fclose()
function in PHP closes an open file pointer.
The feof() function in PHP checks if the end-of-file (EOF) has been reached for an open file pointer.
The fflush() function in PHP flushes the output buffer of an open file pointer.
The fgetc() function in PHP reads a single character from an open file pointer.
The fgetcsv() function in PHP parses a line from an open file pointer as a CSV (comma-separated values) and returns it as an array.
The fgets() function in PHP reads a line from an open file pointer.
The fgetss() function in PHP reads a line from an open file, stripping HTML and PHP tags.
The file() function in PHP reads a file into an array, with each line as an array element.
The file_exists() function in PHP checks if a specified file or directory exists.
The file_get_contents() function in PHP reads the entire content of a file into a string.
The file_put_contents() function in PHP writes data to a file, creating the file if it doesn't exist or overwriting it if it does.
The fileatime()
function in PHP returns the last access time of a specified file.
The filegroup() function in PHP returns the group ID of the specified file.
The fileinode() function in PHP returns the inode number of the specified file.
The filemtime() function returns the last time the file content was modified.
The fileowner() is an inbuilt function in PHP that returns the details for the file owner.
The fileperms() function in PHP is an inbuilt function which is used to return the permissions given to a file or a directory.
The filesize() function in PHP is an inbuilt function which is used to return the size of a specified file.
A file type is usually identified by the file extension and the applications associated with the file.
fnmatch() checks if the passed filename would match the given shell wildcard pattern.
The fopen() function opens the file specified by filename and associates a stream with it.
The fpassthru() function reads from the current position in a file - until EOF, and then writes the result to the output buffer.
fputcsv() formats a line (passed as a fields array) as CSV and writes it (terminated by a newline) to the specified file stream .
fputs() is a standard C library function that is used to write a string of characters to a file at the location indicated by the file pointer.
The fread() function reads up to count items of size length from the input stream and stores them in the given buffer.
The fscanf() function reads data from the current position of the specified stream into the locations that are given by the entries in argument-list, if any.
The fseek() function seeks in an open file.
The fstat() function returns information about an open file.
ftell returns the current position of the file read/write pointer
The ftruncate() function truncates a file to the specified length.
The fwrite() function is used to write to a file.
The glob() function searches for all the pathnames matching pattern according to the rules used by the libc glob() function
The is_dir() function checks whether the specified filename is a directory.
This function returns the value for the process PHP is executing under. /var/somebody/files was only executable by owner (700).
Returns true if the filename exists and is a regular file, false otherwise.
The is_link() function checks whether the specified filename is a symbolic link.
The is_readable() function checks whether the specified filename is readable.
File upload in PHP allows you to upload files with different extensions to the server.
The is_writable() function checks whether the specified filename is writable.
The is_writable() function checks whether the specified filename is writable.
The chgrp() function changes the usergroup of the specified file.
The lchown() function changes the user ownership of a symbolic link.
A hard connection is created for a given target using the link() function.
The linkinfo() function returns information about a hard link, and is used to verify if a link really exists.
The information about a file or symbolic link is returned by the lstat() function.
The mkdir() function creates a directory specified by a pathname. Syntax. mkdir(path, mode, recursive, context).
An uploaded file is moved to a new location using the move_uploaded_file() function.
parse_ini_file() loads in the ini file specified in filename , and returns the settings in it in an associative array.
The parse_ini_file() function parses a configuration (ini) string and returns the settings.
The parse_ini_file() function parses a configuration (ini) string and returns the settings.
The pclose() function closes a pipe opened by popen().
popen() in PHP opens a pipe to a process, allowing you to execute a shell command and read or write to that process.
The readfile() function in PHP reads a file and outputs its contents directly to the browser.
The v function in PHP is not a standard function. Could you clarify what you mean by v? If you're referring to a specific function or feature, please provide more details.
The realpath() function in PHP returns the canonical absolute path of a given file or directory.
The realpath_cache_get() function in PHP retrieves the realpath cache information for a given directory.
The realpath_cache_size() function in PHP returns the amount of memory used by the realpath cache.
The rename() function in PHP renames or moves a file or directory.
The rewind() function in PHP resets the file pointer to the beginning of a file or stream.
The rmdir() function in PHP removes an empty directory.
The set_file_buffer() function in PHP sets the buffer size for file handling operations.
The stat() function in PHP retrieves information about a file or directory, such as its size, permissions, and modification time.
The symlink() function in PHP creates a symbolic link to a specified file or directory.
The tempnam() function in PHP creates a unique temporary file with a specified prefix.
The tmpfile() function in PHP creates a temporary file with a unique name and returns a file handle to it.
The touch() function in PHP sets the access time and modification time of a file, or creates the file if it doesn't exist.
The umask()
function in PHP sets or gets the default permissions mask for newly created files and directories.
The unlink() function in PHP deletes a file.
PHP filters are used to validate and sanitize input data.
Determines if a specified input variable of a given type exists.
Returns the filter ID for a given filter name.
Retrieves an external variable (e.g., from form input) and optionally applies a filter to it.
Retrieve and optionally filter multiple external variables (e.g., from form input) as an array.
filter_list()
is a PHP function that returns an array of all supported filters, which can be used with the filter_var()
and filter_input()
functions.
filter_var() is a PHP function used to filter a variable with a specified filter and optionally sanitize or validate it.
filter_var_array() is a PHP function that filters multiple variables according to the specified filters and options.
PHP FTP is a set of functions in PHP for interacting with FTP servers to perform file transfers and other FTP-related operations.
ftp_alloc() is a PHP function that allocates space for a file to be uploaded to an FTP server.
ftp_cdup() is a PHP function that changes the current directory to the parent directory on the FTP server.
ftp_chdir() is a PHP function that changes the current directory on the FTP server.
ftp_chmod() is a PHP function that sets permissions on a file or directory on the FTP server.
ftp_close() is a PHP function that closes an FTP connection.
ftp_connect() is a PHP function that establishes a connection to an FTP server.
ftp_delete() is a PHP function that removes a file from the FTP server.
ftp_exec() is a PHP function that sends a raw command to the FTP server for execution.
ftp_fget() is a PHP function that downloads a file from the FTP server and saves it to an open file stream.
ftp_fput() is a PHP function that uploads data from an open local file to a file on the FTP server.
ftp_get() is a PHP function that downloads a file from the FTP server and saves it to a local file.