RSSAll Entries in the "Development" Category

PHP syntax errors description

Every programming language has number of rules, called syntax, which must be followed in the constructions in order to be valid. If a construction is not following these rules, then we said that there is a syntax error. Syntax errors often are called parser errors, when we talk about languages like PHP. Other errors could be compiler errors like in C or Java.

If we do not follow the rules when we speak or write to other people, probably they will understand, but when we write a PHP script most probably there will be an error.

If a script is not written correctly according to the rules, the PHP parser will not be able to process a part or the whole script. Within many other rules PHP syntax demands all the constructions to end with semicolon, string to be enclosed in quotes and the parameters to be separated with comas and enclosed within brackets.

The PHP errors are very usefully because they are providing us with information, what is wrong with the script.

For example :

PHP Parse error: syntax error, unexpected T_ECHO in /home//public_html/test/date.php on line 3‘ will be generated by a script where you have forgotten to add semicolon.

PHP script sending with external SMTP authentication

In my work I often have clients calling with the following statement: “My PHP script which is sending with external SMTP authentication is not working. I checked all my code and it appears it is not working because of your (shared hosting) server.”

Well since it is rather not possible all the customer\”s scripts to be checked so I need something to check from the client”s side.

In such case the script provided here is very useful.

Tags

Check MySQL database connection using PHP test script

As a tech I’ve been in situations when a database is not working or the connection to it is interrupted.

This tutorial will show you how can be done MySQL database connection check using PHP script.

Tags

Coloring PHP code output in text

The subject of this tutorial will be how PHP code can be colored when you publish it within page text.
We have had inquires about how we are coloring the PHP code on our pages, so we decided to create a simple tutorial.

There are many ways to, but the one that will work on almost all platforms will be to use the built in option inside PHP.

The option is called ‘highlight_strin()’ and has syntax like:

highlight_string ( string $str [, bool $return = false / true ] )

"It returns a syntax highlighted version of the given PHP code using the colors defined in the built-in syntax highlighter for PHP."

It can be used as for $str you will put the PHP code that you want colored, and for the optional $return you can put ”true” or ”false”, or as we are going to do in our example, to leave it unused.

Let’s take for example a simple MySQL connection test script:

Reading a file in PHP

Reading a file in PHP

This tutorial continues from PHP working with files ‘“ open file where we discussed the function ‘fopen()’ as well its parameters.

One more time I will describe ‘fopen()’ function. Here is the prototype of it:

PHP working with files. Open file

PHP provides real comfort when you are working with files. It does not matter whether they are on the local server ‘localhost’ or on a remote server. There are many cases when you will have to work with the content of different files, for example when you are using simple counters or string treatment of any kind. As well as many other abilities of the language the work with files in PHP is easy and simple.
We will provide the main functions and constructions which will help you to perform operations on the file server as well as work with remote files.

Opening file in PHP.

Before doing anything with any file the first step is to open it. We can do that with ‘fopen ()’ function.

HTML h1,h2,h3,h4,h5,h6 tags

This article will give an example about the general HTML tags.

Example HTML h1 to h6 tags -The six different HTML headings:

<h1>This is heading 1</h1>

<h2>This is heading 2</h2>

<h3>This is heading 3</h3>

<h4>This is heading 4</h4>

<h5>This is heading 5</h5>

<h6>This is heading 6</h6>

Tags

Create a test file

This tutorial will show you how to create a test file under RedHat-like Linux operating systems. It will be useful when you need to test FTP, Mail, Samba or any protocol and you do not have big file handy to send.

To create a test file simply copy the following line in your Linux shell:

PHP info

This tutorial will show you how to display Apache PHP configuration.
It is useful in cases when you are going to install a particular application which needs specific requirements like register_globals or long_array turned On or Off.

This can be done by simply uploading one file, for example ”info.php” with the following code included inside:

Check your PHP version.

This tutorial will show you how to verify PHP version on a server with Unix /Linux operating system. This will be helpful in case when you are installing an application and it requires a specific PHP version.
Login to the server were you want to check and then type:

 

 

Then you should see the listing with the PHP version similar to this one:

 

Check php version

 

There is another way to check PHP version whit FTP file upload of a simple PHP file with function which will display PHP info .

Tags