Home » Search results for 'javascript string'

PHP_SELF – What It Is, and Why It’s Too Dangerous to Use [WARNING]

PHP_SELF

This article outlines the PHP_SELF attribute of the $_SERVER system information variable and why you should never, ever use it. What is _$SERVER? Check out our full article on $_SERVER here – but in short, it’s a variable containing an array with information about your PHP environment – including server and request details that are quite sensitive and shouldn’t be publicly accessible. What is $_SERVER[‘PHP_SELF’] ? $_SERVER[‘PHP_SELF’] contains the full path to the PHP script being executed, including any query parameters. This allows the party making the request to include arbitrary data. Displaying data … Read more

Categories PHP

Home » Search results for 'javascript string'

How to Use the PHP empty() Function

Check if PHP Variable Empty

This easy tutorial will show you how to use the PHP empty() function to check whether a variable can be considered empty and show some code examples. What Is Empty? A variable is considered empty in PHP if its value equates to FALSE or the variable does not exist. This means that the following are considered empty: An empty string (“”) The number zero (0) In any form (0.0000) Including strings containing only a 0 character (“0”) Boolean FALSE NULL An undeclared variable Empty arrays The empty() function is different from the isset() function. The latter checks only whether … Read more

Categories PHP

Home » Search results for 'javascript string'

PHP: Process Each Item In An Array with array_map() [Examples]

PHP array_map

This article will show you how to process a PHP array using array_map() to run a function on each item in the array. Why use array_map()? Arrays store a sequence of values in a single variable. If you’re storing those values, you probably want to do something with them at some point. Say, for example, you had an array of numbers, and you wanted to calculate the square of each number to be stored in a new array. You could create an empty array, loop through the original array calculating … Read more

Categories PHP

Home » Search results for 'javascript string'

What is a Python Dictionary? Explanation and Code Examples

Python dictionary

Here’s everything you need to know about the Dictionary data type in Python, what it can store, and how to use it. Python has several built-in data types for storing data (more than other languages like JavaScript) – from basic types like integers, floating-point numbers, and strings to more complex types like lists, tuples, and dictionaries. What is a Type? A variable’s type defines what kind of value it can store and what can be done with it. What is a Dictionary? A dictionary is a variable type … Read more

Home » Search results for 'javascript string'

How to Execute PHP from the Command Line (Bash/Shell)

Execute PHP from the Command Line/Bash

This article will quickly run through the ways PHP can be used from the Bash shell/command line, with examples. PHP is usually used for generating content to be served on the web – but it can also be used from the command line. This is usually done for the purposes of testing or finding out information about the PHP environment – but PHP can also be used for writing command-line scripts (though, again, it’s not really done that frequently – probably because there are better … Read more

Home » Search results for 'javascript string'

How to Use the MySQL/MariaDB COUNT Function, With Examples

MySQL Count

This quick article will demonstrate how to use the MySQL/MariaDB COUNT function to count the number of records returned by a query. MySQL/MariaDB COUNT Function Syntax COUNT(query) Note that: query can be an SQL query or a string representing a column name Null values found by the query will not be counted The COUNT function will return the number of matching records for a query and should be combined with the SELECT statement to output the result. Example Data The below examples use the following … Read more

Home » Search results for 'javascript string'

HEREDOC (Here Documents) in Bash and Linux Shell – Tutorial

Bash Heredoc

This article will show you how to use a Heredoc (Here Document) in Bash/Shell scripts to work with multi-line text. Heredocs are most useful for accepting multi-line input- the user can enter a line of text, press enter, then enter the next line, and so on. It can also be used to define multi-line text in scripts. It can also send multiple commands into an interactive program – this will be shown in the examples later. The examples in this article will work in both … Read more

Home » Search results for 'javascript string'

The tr Command in Linux – What It Is and How To Use It

Linux tr Command

The tr (translate) command in Linux reads text from standard input, performs some modification to the text, and then sends it to standard output. This article explains and shows why and how you might use it. tr Command Syntax Here’s the syntax you’ll need to use the command: tr OPTIONS SET1 [SET2] Note that: OPTIONS should be a list of options from the below table The characters in SET1 will be replaced with the characters in the corresponding position in SET2 These are optional – some of the OPTIONS are capable of performing translations, … Read more

Home » Search results for 'javascript string'

Python lstrip and rstrip Methods – With Examples

Python lstrip and rstrip Methods

This short tutorial will show you how to use lstrip and rstrip to remove whitespace (or any other characters) from the beginning/end of strings in Python. The lstrip and rstrip methods are available on any string type variable in Python 3. Python lstrip String Method The lstrip (Left strip) method will remove leading characters from the string – that is, characters starting from the left of the string. Syntax Here’s the syntax for the lstrip method: string.lstrip(characters) Note that: string can be any string value or variable with a string value characters is an optional parameter for the lstrip method These are the characters that … Read more

Home » Search results for 'javascript string'

Converting Variable Types in Python, Howto, With Examples

Python Type Conversion

This article will show you how to use Python’s built-in variable conversion functions, with examples. A variable’s type determines what kind of data it can store and what can be done with it. For example, string typed variables contain sequences of characters that can be joined and split (think words and sentences). In contrast, numeric typed variables contain numeric values intended to be used in calculations. Being able to convert a variable’s type allows data to be used in different ways. Converting a Variable to a … Read more