Tuesday 27 December 2016

The most important functions in PHP

Whether you are learning or new to porgramming in PHP there are a dozens of important php functions you should get hold of at first.

This will make your life lot easier if you know about these functions. And you should remember them by heart if you want to be very very good programmer because with time you could do the same with any other language.

Most of programmers who want to be serious in development field lack the courage to do the first step right, which is to be master in the basics functionality of any language. And believe me the easiest task on any programming language is basically connecting to a database, and execute some quries, list data etc.)

But when life becomes tougher, we encounter logic and write code for a very complex task, these functions are our babies which we should love most... Because, like a good child, these functions are going to save us the way our children do in our old-age.

Most important ARRAY functions in php

  • is_array() - Well name describe everything 
  • count($array) => returns the number of elements etc (if array is empty = it will return 1)
  • sizeof($array) => same as count()
  • empty($array) => whether or not an array is empty
  • end($array) => returns the last element in an array
  • array_diff($array1,$array2) => returns the difference in two arrays 
  • array-add($array1,$array2) => adds two arrays
Most important STRING functions in php

  • str_replace() => search and replace anything in a string
  • strpos() => find the position of a string if it exists.. (like checking if a word exists in a text)
  • substr() => get a portion of string by position
  • strstr() => get a portion of string as well.
  • strlen() =. find the length of string


No comments:

Post a Comment