Home » Programming

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

How To Run a Python Script (Python 2/3)

How to Run Python Scripts

This article will show you how to run both Python 2 and Python 3 scripts in Linux and find out what versions of Python are installed. Running a Script To run a Python 3 script: python3 /path/to/script.py To run a Python 2 script: python2 /path/to/script.py Read on to find out how to install Python and find out which versions you have installed. Installing Python on Linux You can see what Python packages are installed on your system by running the following commands: which python which … Read more

Home » Programming

Checking Whether a String Contains a String in Python, With Examples

Python String Contains

This article will show you how to check if a string contains another string in the Python programming language. PHP and Javascript both have similar functions included: PHP strpos Function: Check if a String Contains Another String Javascript String includes() Method – Check if a String Contains Another String Python has several methods for accomplishing the same thing – read on for how to do it. Using in to Check if A String Contains a String in Python The fastest and best way to check if a … Read more

Home » Programming

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

Using The isNaN() Function in JavaScript, With Examples

JavaScript isNan()

isNaN() is a JavaScript function that will tell you whether a value is equal to NaN – or Not a Number. It can be used to determine whether the result of a mathematical operation is valid or not. Here’s how to use it. What is NaN? NaN is a special value that means Not a Number. It means that a value that should be a number could not be parsed as a number. Any mathematical operation between any other value and NaN will result in NaN. It usually means something has … Read more

Home » Programming

Merge Tables in MySQL (UNION/MERGE TABLES) – Tutorial

MySQL Merge Tables

There are one of two things you might be looking for – merging two MySQL tables, or the MERGE TABLE syntax – this article explains both, with examples. Merging Tables in MySQL (Moving Data From One Table Into Another) A note before I get to the code – if you’re moving data from one table to another, you should take into account the contents of the data and ensure that it will still be valid when merged with the second data set. This is particularly important if … Read more

Home » Programming

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

Show Privileges in MySQL/MariaDB using SHOW GRANTS, With Examples

MySQL Show Privileges

This article will show you, with examples, how to show what database privileges users have in MySQL and MariaDB. List All Users To show the privileges for a user, you need to be able to query the user’s name. Here’s how to generate a list of all users on a MySQL server: SELECT user FROM mysql.user; …and here’s how to list all users, with the host they are allowed to connect from: SELECT user, host FROM mysql.user; Both of the above queries pull information from … Read more

Home » Programming

Calculating Absolute Values in Python, With Examples

Python Absolute Value

In this article, you’ll learn about absolute values – what they are, how they’re used, and how to use the Python abs() function to calculate them. What is the Absolute Value of a Number? The absolute value of a number is that number’s value without any regard to its sign. A number’s sign is whether it is positive or negative. So, the absolute value of a number is never negative. To make it simple, consider the absolute value of a number that numbers distance from 0. It is also referred to in mathematics and … Read more

Home » Programming

Command Line Arguments in Python Scripts, With Examples

Python Command Line Arguments

This article will show you simple methods to pass command line arguments to your Python scripts, with some examples. Passing arguments to your script makes it easy to build multi-use scripts that can work on different inputs. This is much easier than re-editing your code every time you want to change the inputs it will be working on. I’ve previously covered building a full command-line application in Python, which accepts command-line options and bundles the application into a distributable package with no external dependencies – … Read more