Home » Programming

How to Declare Variables in PHP (Constants, Static, Global)

PHP Declare Variable

This article shows you how to declare variables in PHP, including constant, static, and global variables. Code examples are provided. What is a Variable? In computer programming, a variable stores a value, giving it a name that can be used to access it. Once a variable has been created and a value has been assigned to it, the value can be retrieved using the name given to the variable. The value of a variable can be updated (unless the variable has been declared as a constant), and the … Read more

Categories PHP

Home » Programming

How to Check What Version of PostgreSQL You are Running on Linux

PostgreSQL Check Installed Version

This article will show you how to check the version (or versions) of PostgreSQL running on your Linux system. As it is possible to install multiple versions of PostgreSQL on the same machine, there are a few ways to check the running version, which are detailed below. Checking PostgreSQL Server Version To check the running PostgreSQL server version, use the following pg_config command: Check PostgreSQL Client Version To check which version of the PostgreSQL client you are running, run the following psql command: Finding the PostgreSQL Executables If you … Read more

Home » Programming

Safely Using PHP Variable Variables with Arrays [Examples]

PHP Variable Variables and Arrays

PHP variable variables are a powerful way to add flexibility to your code. This article explains the pitfalls and solutions to using them with arrays. Variable variables are a great way to simplify your code and make it more readable. However, when using them with arrays, you need to be careful. PHP Arrays and Variable Variables To use variable variables with PHP arrays, extra considerations need to be taken to resolve potential ambiguities in your code. Consider the following PHP code: To what exactly is the array key … Read more

Categories PHP

Home » Programming

How to Test Connection to PostgreSQL Database on Linux (Ubuntu/Debian/Fedora)

Test Connection to PostgreSQL Server Database

This short tutorial will demonstrate how to test the connection to a PostgreSQL database locally and remotely from Linux. This article is part of our series on getting started with PostgreSQL, head back to our index that lists our full PostgreSQL guide. Testing PostgreSQL Database Connection on Ubuntu/Debian To test connectivity to a PostgreSQL server, you’ll need the PostgreSQL client installed if it is not already. Do this by running: Then, you can use the pg_isready command to test the connection to a database: One of the following … Read more

Home » Programming

Is PostgreSQL an SQL or NoSQL Database?

PostgreSQL is not NoSQL

A common question is whether PostgreSQL is an SQL or NoSQL database (it’s not) – this article explains why. What is SQL SQL (pronounced sequel or S-Q-L) is the Structured Query Language – a language used by many relational database systems for querying data. It is also increasingly being used for defining data schemas in data analytics applications where the data is not stored in a database but is arriving as a data stream. Data defined and queried by SQL is structured tables that can have relationships between records – for example … Read more

Home » Programming

How to Include a JavaScript File in Another JavaScript File [Examples]

How to Include a JavaScript File in Another

This article will detail the various methods for including a JavaScript file in another JavaScript file – providing several methods for use in the browser, and when working in Node.js. One of the cornerstones of programming is reusable code. This concept is encapsulated in the DRY (Don’t Repeat Yourself) principle – that if you need to do something multiple times, you write the code for it once, and re-use it where it is required, rather than having multiple copies of the same code in your code base. … Read more

Home » Programming

JavaScript Reference: Complete List of Operators + Examples

JavaScript Operators

This article will explain and list JavaScript operators and expressions. JavaScript operators perform a given operation on the provided expressions or values. Common operations include comparisons, arithmetic, and ternary operations. You will use JavaScript operators frequently (even the simplest JavaScript code will use multiple operators!), so it’s worth getting to know them, and their expected behaviour. What are Operators and Operands? Javascript operators perform a given operation, for example addition, subtraction, and other arithmetic, comparisons like greater than/less than, and more complicated operations like ternary/comparison … Read more

Home » Programming

PHP Scopes in Functions, Loops, Modules, With Examples

PHP Variable Scopes

This article explains what variable scopes are, and how they work in the PHP programming language, with code examples. When programming in any language, you must be aware of how variables are scoped – otherwise, you risk unexpected behaviour, including incorrect calculations, or loss of data – detrimental outcomes for any application (especially if you are working with business records or financial data) that will result in angry users. What is a Variable? In computer programming, a variable stores a value, giving it a name that can … Read more

Categories PHP

Home » Programming

Python NumPy Crash Course – A Simple Tutorial and Example

Python Numpy Course Tutorial Example

Python’s NumPy library is the standard for working with numerical data. This article will explain why that is, and how to use it. In addition to this, code examples for basic usage will be shown, and we will build a real-world example that implements NumPy to work with some example data. Python and Arrays Whether you are working with data collected for scientific or business reasons, it is usually collected in the form of arrays of data presented as tables with single or multiple columns. … Read more

Home » Programming

Python Virtual Environments with virtualenv and Anaconda

python virtualenv

This article will explain and demonstrate virtual environments in Python using virtualenv and in Anaconda. What is a ‘Virtual Environment’? In Python, a virtual environment is an isolated directory that contains all of the dependencies of a Python project. By default, when you install a package using the pip package manager, it is installed globally – that version of the package is available to all Python scripts running on your system. This can cause problems. It clutters up your global Python installation, and all projects … Read more