Home » Programming » PHP

Refresh or Redirect a Page using PHP, With Examples

PHP Refresh Page

This article will show you how to refresh a web page in the browser using the PHP programming language. It’s sometimes necessary to set a page to reload automatically, usually at some interval, to keep the page updated with changing information. For example, you may have a scoreboard application that is displayed in a web browser on a projector and wish to have it periodically refresh to keep the displayed scores up to date with those stored. Periodic refreshing is also used to redirect to … Read more

Categories PHP

Home » Programming » PHP

Multidimensional Arrays in PHP – How To Use, With Examples

PHP Multidimensional Arrays

This article will show you how to use multidimensional arrays in the PHP programming language, explaining what they are and how to use them. What is an Array? An array is a type of PHP variable that can hold multiple values. It’s a list of values you can loop through and perform operations on each individual value. For example, you might want to perform an action on a list of files. By storing that list as an array, you can loop through the file names … Read more

Categories PHP

Home » Programming » PHP

PHP vs HTML – What’s The Difference? Which Should You Use?

PHP vs HTML

This article will explain the difference between PHP and HTML and outline which you should use for your project (probably both – and I’ll explain why). If by the end of this article you’re still trying to navigate your way through the different web programming languages, check out these other explainers: jQuery vs. JavaScript – Differences? Which is Better? PHP vs. JavaScript – The Best Choice For Your Project TypeScript Vs. JavaScript – What’s the Difference & Which Should You Use? MySQL vs. MariaDB vs. … Read more

Categories PHP

Home » Programming » PHP

Passing Variables by Reference in PHP, with Examples

PHP Pass Variable By Reference

This article will explain how to pass a PHP variable by reference and why you might want to do it – with some examples. What is a Variable? You probably already know this one. A variable stores a value – it has a name, and you can use that name to refer to the variable and the value it contains. In PHP, variable names are prepended with a $ (dollar symbol) and must contain only numbers, letters, dashes, and underscores: $variableName = “Variable Value”; Variable Behaviour in … Read more

Categories PHP

Home » Programming » PHP

PHP Validator – Safely Checking Your PHP Code Syntax Quickly and Easily

PHP Validator

This is a quick “now you know” article showing you how to validate your PHP code using PHP from the command line instead of using an online PHP validator. Online PHP Validators So, you’ve got some PHP code, and you want to check that it’s valid—a pretty common scenario. Maybe there’s a bug in it you can’t find; maybe your web host doesn’t allow you to view errors to debug. You probably just search for ‘PHP Validator’ and paste your code into the text box on … Read more

Categories PHP

Home » Programming » PHP

PHP include – How to Use It, With Examples

How to use PHP include

The PHP include expression allows you to import code from another file and import code from external PHP libraries. Here’s how to use it, with examples. PHP include will execute and import PHP code from another file or library.  It allows you to re-use code and work with libraries provided by others – for example, you may download a library to interact with a mapping service and wish to include it in your code. Syntax include ‘./path/to/file.php’; Simple! The include expression must be followed by the … Read more

Categories PHP

Home » Programming » PHP

How to use the PHP parse_url() Function, With Examples

PHP parse_url

The PHP parse_url() function processes a given URL and divides it into its individual components.  Here’s how to use it. parse_url() is often used to get the host/domain name from a given URL or the path to a remote host file. Syntax for parse_url() parse_url ( $url , $component ) Note that: $url is the URL (e.g., https://www.linuxscrew.com) which you want to parse Relative URLs may not be parsed correctly $component is optional and can be one of: PHP_URL_SCHEME, PHP_URL_HOST, PHP_URL_PORT, PHP_URL_USER, PHP_URL_PASS, PHP_URL_PATH, PHP_URL_QUERY or PHP_URL_FRAGMENT … Read more

Categories PHP

Home » Programming » PHP

PHP isset() – Check if A Variable is Set, With Examples

Using PHP isset()

This article shows you how to use the PHP isset() function to check whether a variable exists and is populated. So, it’s checking if a variable is set. Why would you want to do this? You can’t perform actions on a variable that doesn’t exist or that has no value – you’ll either get unexpected output or an error. So, being able to check that a variable is set and is populated is pretty useful. Syntax for isset() isset ( $var1 , $var2…) Note that: $var1 should be … Read more

Categories PHP

Home » Programming » PHP

PHP vs JavaScript – The Best Choice For Your Project

PHP vs JavaScript

PHP and JavaScript are the most commonly used programming languages on the web – so which one should you use for your project? Check out our recent article on JavaScript vs. Node.js for another commonly searched programming comparison. Choosing which programming language to use for a project is important. Some of the questions you’ll want to run through are: Where will the application be run, and which languages are supported in that environment? Do I already have knowledge of one of the languages being considered? … Read more

Home » Programming » PHP

PHP Timezones- How to Set/Change Timezone, With Examples

Managing PHP Timezones

This article provides a combined tutorial for the PHP timezone functions, showing how to change the timezone globally or temporarily for a script/object. Timezones are a huge hassle. If your app has users from around the world, you’ll eventually run into the annoying task of ensuring that date handling works effectively for everyone – including the accuracy of times displayed and the format they are displayed in. PHP provides several tools to make timezone handling easier, allowing you to set the default timezone for the system, a … Read more

Categories PHP