PHP Logo

String Variables in PHP

String variables are used for values that contains characters. In this chapter…

String variables are used for values that contains characters.

In this chapter we are going to look at the most common functions and operators used to manipulate strings in PHP.

After we create a string we can manipulate it. A string can be used directly in a function or it can be stored in a variable.

Below, the PHP script assigns the text “Hello World” to a string variable called $txt:

<?php
$txt="Hello World";
echo $txt;
?>

The output of the code above will be:

Hello World

Now, lets try to use some different functions and operators to manipulate the string.

PHP Logo

Variables in PHP

Variables are used for storing a values, like text strings, numbers or…

Variables are used for storing a values, like text strings, numbers or arrays.

When a variable is declared, it can be used over and over again in your script.

All variables in PHP start with a $ sign symbol.

The correct way of declaring a variable in PHP:

$var_name = value;

New PHP programmers often forget the $ sign at the beginning of the variable. In that case it will not work.

Let’s try creating a variable containing a string, and a variable containing a number:

<?php
$txt="Hello World!";
$x=16;
?>

PHP Logo

Basic PHP Syntax

A PHP scripting block always starts with <?php and ends with ?>.…

PHP Logo
PHP Logo

A PHP scripting block always starts with <?php and ends with ?>. A PHP scripting block can be placed anywhere in the document.

On servers with shorthand support enabled you can start a scripting block with <? and end with ?>.

For maximum compatibility, we recommend that you use the standard form (<?php) rather than the shorthand form.

<?php
?>

A PHP file normally contains HTML tags, just like an HTML file, and some PHP scripting code.

Below, we have an example of a simple PHP script which sends the text “Hello World” to the browser:

Computer management

Wireless Zero Configuration in Windows XP

Wireless zero configuration is the feature of Windows XP that allows Windows…

Wireless zero configuration is the feature of Windows XP that allows Windows to detect the available wireless networks and automatically connect to the most preferred wireless network.

It is enabled by the Wireless Zero Configuration service in Windows XP. It provides auto wireless network detection when you switch on the computer.

Follow the steps below to verify that the service is running:

1. Go to Start and right click My Computer. Select and click Manage.

2. Computer Management window will appear. Under Services and Applications, select Services.

3. Check for the service Wireless Zero Configuration. Make sure that it is started and that the startup type is set to automatic.

Computer management
Computer management
Download Ubuntu Server

How to Setup a Dedicated Web Server for Free!

1. A Quick Overview In this tutorial, we are aiming to accomplish…

1. A Quick Overview

In this tutorial, we are aiming to accomplish several things:

  •  We’re going to install the Ubuntu Server operating system. I commonly use Ubuntu because of its ease of use and simple administration. It also has a rather large and extremely active community behind it, which makes getting support a breeze.
  • We’re going to install an OpenSSH server. This allows you to administer your server from remote computers.
  • A LAMP (Linux, Apache, MySQL, and PHP) stack is going to be installed. This provides the backbone that will run your web site. Apache is the industry standard web server on Unix-based operating systems; it’s what most web hosts use (NETTUTS is using it right now!) and it’s what we’re going to use.
  • We’re going to install a firewall to protect your server from unauthorized access.

In order to follow this tutorial, you’re going to need a few items:

  • A computer to use as your server. It doesn’t need to be powerful; as long as it’s not ancient, it’ll work fine. Please don’t do this on your desktop PC; Ubuntu will completely wipe your computer.
  • A CD burner and a blank CD. These are so that you can burn Ubuntu to a disk in order to install it.
  • Time. Seriously, this process is time-consuming, especially if you run into problems. Try to set aside an afternoon to follow this tutorial.

You may be asking why you’d want to have your own web server. There are several reasons, a few of them being: you can have your own testing ground for your websites; with a little modification, you could host your own site; and, you will learn a lot about Linux/Unix as you go.

With that said, let’s get started!