JavaScript: How to use the conditional ternary operator

In addition to “normal” comparison operators (see the links below), JavaScript has a unique comparison operator that can assign values rather than just return a boolean true or false. This is called the “Conditional (Ternary) Operator”.  It follows this syntactical construction: variablename = (condition) ? value1 : value2 The question mark means: If the condition … Continue reading JavaScript: How to use the conditional ternary operator

Apache: How to change the server name from localhost to custom name

I recently installed the Bitnami WAMP stack which simultaneously installs Apache 2, PHP, and MySQL. The default domain name when installing Apache server is either “localhost” which is found at the default IP address of 127.0.0.1. For example, web pages can be found at: http://localhost/ http://127.0.0.1/ and scripts in the cgi-bin can be accessed like … Continue reading Apache: How to change the server name from localhost to custom name

HTML: How to get vector icon images into your web page using Font Awesome

FontAwesome is a website where you can get free vector Icon images for your website. As described on their “get-started” page, they offer a CDN (Content Delivery Network) URL that you can place into your web page and the SVG icons will be loaded asynchronously into the page: https://fontawesome.com/get-started Here is what the CDN would … Continue reading HTML: How to get vector icon images into your web page using Font Awesome

HTML: How to get random stock images on your web page using unsplash.com

The website https://unsplash.com provides a free service that allows web developers to use random images of any size on their websites. All you have to do is place a URL like this in your HTML img tag, with the size of the image listed at the end of the URL. For example, this will produce … Continue reading HTML: How to get random stock images on your web page using unsplash.com

PHP: How to print information about variables, arrays, and objects

To print information about variables, arrays or objects in PHP, we can use the following functions: print_r() var_dump() var_export() print_r( ) According to this explanation on stackoverflow.com, print_r(): Outputs a human-readable representation of any one value Accepts not just strings but other types including arrays and objects, formatting them to be readable Useful when debugging … Continue reading PHP: How to print information about variables, arrays, and objects

PHP: How to output text, variables, and HTML markup using print and echo

In PHP there are two ways to “print” HTML markup, text, and variables, using print and echo. These are essentially interchangeable, though print is slower, so best practice is to use echo. “print” has a return value of 1 (so it can be used in expressions), while “echo” does not.  print can take one argument, … Continue reading PHP: How to output text, variables, and HTML markup using print and echo