PHP Magic Book – Free PHP Scripts, Tutorials and Downloads, PHP AtoZ Reloaded, free php tutorials, free php downloads, php scripts, PHP tips

Archive for the ‘ PHP Basics ’ Category

Show A Part Of String – substr in PHP

Recently I was working with some PHP project and I had to fetch some text from database but I did not want to show all the paragraph. Instead I wanted to display just some part of it and give the reader facility to have a link or read more.

For example:
If the original text is
PHP is a great programming platform where we can do anything relating to dynamic web pages and huge websites.
I wanted to display just a part of it like this.
PHP is a great programming platform…

In this case we use substr which returns a part of string. It means substr returns the portion of string specified by the start and length parameters.

(more…)

Tags: , ,
Posted in: PHP Basics, PHP Functions, substr
Post's RSS » RSS 2.0
Post's Comments RSS » RSS 2.0
Respond: Post A Comment

PHP Post And Get

Post and Get are both used in forms to pass data from one page to another but there is a slight difference in both. Consider we have a form containing user name and password fields. On submit it goes to page named as submit.php. Now the behavior of form with these two get and post methods will be different as described below:

(more…)

Tags:
Posted in: PHP Basics, Post & Get
Post's RSS » RSS 2.0
Post's Comments RSS » RSS 2.0
Respond: Post A Comment

PHP Arrays

An array is a data structure that stores one or more values in a single value. In more detail ‘An array’ in PHP is actually an ordered map. A map is a type that maps values to keys. This type is optimized in several ways, so you can use it as a real array, or a list (vector), hashtable (which is an implementation of a map), dictionary, collection, stack, queue and probably more. Because you can have another PHP array as a value, you can also quite easily simulate trees.

An array can be created by the array() language-construct. It takes a certain number of comma-separated key => value pairs.

(more…)

Tags: ,
Posted in: Arrays, PHP Basics
Post's RSS » RSS 2.0
Post's Comments RSS » RSS 2.0
Respond: Post A Comment

PHP Strings

Before you can use a string you have to create it! A string can be used directly in a function or it can be stored in a variable. Below we create the exact same string twice: first storing it into a variable and in the second case we place the string directly into a function.

(more…)

Tags: ,
Posted in: PHP Basics, Strings
Post's RSS » RSS 2.0
Post's Comments RSS » RSS 2.0
Respond: Post A Comment

Local And Global Variable Scope in PHP

Variable Scope

The scope of a variable is the context within which it is defined. For the most part all PHP variables only have a single or local scope. This single scope spans included and required files as well.

(more…)

Tags: ,
Posted in: PHP Basics, Variable Scope
Post's RSS » RSS 2.0
Post's Comments RSS » RSS 2.0
Respond: Post A Comment



  Subscribe Via RSS
  Subscribe Via Email