Phpdynamic

PHP and MySQL Programming Guides, Tutorials, & Articles

Archive for Beginners

What are Constants?

MAR 25

PHP Constants

A constant represents a literal value that will remain the same, for example the value for PI (3.14), the number of days in a week (7), or the number of ounces in a pound (16) all represent numbers that will never change. A constant can store a value similar to a variable, but that value cannot be modified during the execution of a script, once that constant is initialized. Constants are created using the built-in define() function, by assigning an identifier name to the constant along with a literal value.

Read more…

What Are Variables?

MAR 18

PHP Variables

We can all probably remember variables from algebra class during our high school years, remember expressions like x + 2 = 10 or something fun like 5x(-3x3)2 ? Well, maybe some of us can, don’t worry were not going to be solving any equations here. Anyways, besides this nostalgic moment, how do variables fit into the picture?

A variable is a location in a computer’s memory, identified by a symbolic name, that can hold different values of data at different times during the execution of a program. Variables can store and retrieve data that is essential to your scripts, things like the number of visitors to your website, the total amount due at checkout, the name of the person currently logined in, or the age of the user can all be stored in variables.

Read more…

Using PHP to Generate Output

MAR 18

The echo() Statement

Without displaying any output, we probably won’t be able to accomplish anything useful with our scripts, hence PHP provides several different methods of passing output to the web browser and essentially providing the user with some feedback. In particular, we’ll cover the echo() statement and the print() statement, which are the two most common ways of displaying output to the browser.

Referring back to our “Hello World” example, you can probably guess what the echo() statement does. It simply displays or echoes output directly to the browser, in this case the string “<p>Hello World!</p>” was passed to the browser and displayed to the user.

<html>
<head>
  <title>Hello World Script</title>
</head>
<body>
<?php
  //this is some php code
  echo '<p>Hello World!</p>';
?>
</body>
</html>

Read more…

Beginning PHP – Language Syntax

MAR 11

Syntax and Semantics

All programming languages must follow a proper syntax, which is a set of rules that control the arrangement of words, numbers, and symbols for writing valid code; and PHP is no exception. In the same sense that English sentences have to follow certain grammatical rules to have a proper meaning (semantic), all PHP statements must follow a certain set of syntax rules to execute correctly.

Read more…

Beginning PHP – The Fundamentals

MAR 10

The Whole Picture

You have an operational web server with PHP installed and configured, and you might be wondering how all the pieces fall together and perform anything useful. Before we move along any further, we would like to share the underlying concept on how PHP and Apache work together; as this will provide you with a solid foundation to understanding the examples used throughout the tutorial.

Read more…

Getting Started with PHP

MAR 10

What is PHP?

PHP is a general-purpose scripting language that is widely used for web development. The official name for PHP is Hypertext Preprocessor, it is embedded directly within an HTML page and interpreted by the web server every time the page is loaded. One of PHP’s greatest advantage is its practical and simple design, allowing both beginning and experienced programmers to quickly develop dynamic content for websites and larger web applications.
Read more…