Category: PHP Tutorial

python tutorials and learn python

Created with Sketch.

PHP date

PHP date Summary: in this tutorial, you’ll learn how to use the PHP date() function to format a timestamp using a specified format. Introduction to the PHP date() function The date() function formats a timestamp using a specified format: date(string $format, int|null $timestamp = null): string Code language: PHP (php) The date() function has two…
Read more

PHP time

PHP time Summary: in this tutorial, you’ll learn how to work with the PHP time() function to get the current timestamp in the local timezone. Introduction to Unix timestamps Computers store a date and time as a UNIX timestamp or a timestamp in short. A timestamp is an integer that refers to the number of…
Read more

PHP preg_replace

PHP preg_replace Summary: in this tutorial, you’ll learn how to use the PHP preg_replace() function to search and replace using regular expressions. Introduction to the PHP preg_replace() function The preg_replace() function searches for matches and replaces them with a pattern. The following shows how to use the preg_replace() function with a single string: preg_replace( string…
Read more

PHP preg_match_all

PHP preg_match_all Summary: in this tutorial, you’ll learn how to use the PHP preg_match_all() function to search for all matches to a regular expression in a string. Introduction to the PHP preg_match_all() function The preg_match_all() function searches for all the matches to a regular expression in a string. Unlike the preg_match() function that stops searching…
Read more

PHP preg_match

PHP preg_match Summary: in this tutorial, you’ll learn about the PHP preg_match() function to match a regular expression. Introduction to the PHP preg_match() function The preg_match() finds the string for a match to a regular expression. The preg_match() function stops searching as long as it finds the first match. Here’s the syntax of the preg_match()…
Read more

Regex Lookbehind

Regex Lookbehind Summary: in this tutorial, you’ll learn about the regex lookbehind and negative lookbehind. Introduction to the regex lookbehind Suppose you have the following string: ‘2 chicken cost $40’; Code language: JavaScript (javascript) And you want to match the number 40 after the $ sign but not the number 2. To do that, you…
Read more

Regex Lookahead

Regex Lookahead Summary: in this tutorial, you’ll learn to use the regex lookahead and negative lookahead. Introduction to the regex lookahead Sometimes, you want to match A but only if it is followed by B. For example, suppose you have the following string: 2 chicken weigh 30lb Code language: PHP (php) And you want to…
Read more

Regex Alternation

Regex Alternation Summary: in this tutorial, you’ll learn about regex alternation, which is simply an “OR” operator in the regular expression. Introduction to the regex alternation Regular expressions use the pipe character (|) to denote an alternation. The alternation is simple the OR operator in the regular expressions. For example, the following pattern uses the…
Read more

Regex Backreferences

Regex Backreferences Summary: in this tutorial, you’ll learn how to use the regex backreferences and their practical applications. Introduction to Regex Backreferences When constructing a regular expression, you can put \n within the pattern. In this case, the \n is a backreference of a capturing group number n. Regex Backreference examples Let’s take some examples…
Read more

Regex Capturing Groups

Regex Capturing Groups Summary: in this tutorial, you will learn how to use the regex capturing groups to group and capture parts of a match. Introduction to the regex capturing groups Suppose you have a URI with the following format: ‘posts/25’ Code language: PHP (php) The URI has a resource name (posts) and id (25).…
Read more