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 Functions ’ 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

isset Function in PHP – Check for any Variable if it is Set or Not in PHP

isset — Determine whether a variable is set or not! Returns TRUE if var exists; FALSE otherwise. If a variable has been unset with unset(), it will no longer be set. isset() will return FALSE if testing a variable that has been set to NULL. isset() only works with variables as passing anything else will result in a parse error. For checking if constants are set use the defined() function.

(more…)

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

PHP – Implode

The PHP function implode operates on an array and is known as the “undo” function of explode. If you have used explode to break up a string into pieces or parts or just have an array of stuff you can use implode to put them all into one string.

(more…)

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

PHP – Explode

The PHP function explode lets you take a string and blow it up into smaller pieces. For example, if you had a sentence you could ask explode to use the sentence’s spaces ” ” as dynamite and it would blow up the sentence into separate words, which would be stored in an array. The sentence “Hello, world, PHP is amazing language.” would look like this after explode got done with it:

1. Hello,
2. world,
3. PHP
4. is
5. amazing
6. language

(more…)

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

PHP Functions

A function is just a name we give to a block of code that can be executed whenever we need it. This might not seem like that big of an idea, but believe me, when you understand and use functions you will be able to save a ton of time and write code that is much more readable!

Suppose you have to use something again and again in PHP code. Then we can create a function and put that thing in function and recall it in the code whenever, wherever and how-much-ever we want it. This saves our time and code size.

(more…)

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

    


  Subscribe Via RSS
  Subscribe Via Email