Category: Php

Some Imp PHP Functions: Hi Readers, Today in this tutorial we have explained some of the PHP Functions which is generally used in your Project or Program in Between.

explode():

This PHP Function is used to Split a Character Array i.e String at a particular Position or Symbol. This Symbol is referred as a Delimiter.

In other words, we can say that If we want to break a String into Smaller pieces at a particular point we can use a explode() functions in PHP.

Here is Simple Example which clears the concept of explode() functions.

<!DOCTYPE html>
<html>
<body>
<h3>Use of Explode() Function, Here Delimiter: " " (Space)</h3>
<?php
$string="explode() function break the String into smaller pieces!";
$result=explode(" ",$string);
print_r($result);
?>
</body>
</html>

ScreenShot:

Some Imp PHP functions


implode():

This PHP Function is used to combines all elements of an array into a String using a Delimiter. A Delimiter can be any symbol (%,/,*,etc…),

any character, word, String, and even it can be an empty String (” “) i.e., Space in between two words.

In other words, we can say that If we want to Join pieces of String or no of characters into a long String we can use an implode() functions in PHP.

Here is Simple Example which clears the concept of implode() functions.

Use of Implode() Function, Here Delimiter: ” ” or / (Slash) or (..)

<!DOCTYPE html>
<html>
<body>
<h3>Use of Implode() Function, Here Delimiter: " "Space or /(Slash) or ..(point)</h3>
<?php
$array=array('implode()','function','is','used','to','join','a','character','array','into','string','using','Delimiter');
$result=implode(" ",$array);
$result1=implode("/",$array);
$result2=implode("..",$array);
echo "$result<br /><br />$result1<br /><br />$result2";
?>
</body>
</html>

ScreenShot:

Some Imp PHP Functions


ctype_alnum():

This function is generally used when we want to check for the given String contains Alphanumeric Character(s) or not

Syntax:

bool ctype_alnum ( string $txt )

here, $txt: any given String which we want to check for Alphanumeric Characters

As ctype_alnum() is a boolean function so it will return either TRUE or FALSE.

Here is Simple Example which clears the concept of ctype_alnum() functions.

<?php
$string= array('A1234bCsghjks', 'wrong!%WA#$gh');
echo "string[0]=>$string[0],<br />string[1]=>$string[1]<br />";

foreach ($string as $case) {
 if (ctype_alnum($case)) {
 echo "<br />String <b>$case </b>consists of only alphanumeric Characters i.e., letters or digits.<br />";
 } else {
 echo "<br />string <b>$case</b> does not consist Alphanumeric Characters i.e.,only letters or digits.\n";
 }
}
?>

ScreenShot:

Some Imp PHP Functions


Some Similar functions as ctype_alnum() are as follows:

ctype_alpha():

This boolean function returns TRUE if all the characters in given string are Alphabets only i.e., it does not contain digits or any Symbols or Special Characters.

ctype_digit():

 This boolean function returns TRUE if all the characters in given string are Digits only i.e., it does not contain Alphabets or any Symbols or Special Characters.


I Hope You would like this tutorial on Some Imp PHP Functions!

Define PHP

Define Php:- First of all, one should know that PHP is one of the most Powerful tools for developing a web application and dynamic website A well as it is generally known as the server-side scripting language. It is scripting language which always executes on server side

Official Website of Php Language:- https://secure.php.net/

Explanation

Php is Open source platform language which is used most widely nowadays. Open Source Language means free to download i.e. not a commercial language where you have to pay for downloading it. If you have core knowledge about PHP and if you found any bug in libraries of PHP you can also debug that bug that’s why it is called Open Source.

Use of PHP

Php is the most popular language and alternatives of many other same platform languages like JSP, ASP, etc.I would like to tell you that “Facebook” one of the popular social sites is also built on PHP. Not only Social Site, Php also provides powerful and most stable blogging tools.Which is now get very popular and known as “WordPress”

WordPress is open source Blogging tool and Content Management System tool which are built using PHP.

Php is an HTML Embedded scripting language it means that you can program HTML language in PHP file. All the File of PHP always saves in the .php file extension.

<!DOCTYPE html> 
<html>
<body>

 <?php  echo "Mindtrickpages first blog!";   ?>   // php code
</body>
</html> 

In above example,  you can see that embedded HTML code within PHP File.


Performance of PHP

It is one of the fastest running Scripting languages.Website built on PHP are very fast as compared to other Scripting Language website.

To Learn php You should have knowledge about following points:-

Html

CSS (Cascading Style Sheet)

JavaScript Language

Php Code

Note:

Php can be connected to any database available in the market like Oracle, MySQL Server, IBM Db2, PostgreSQL, and MySQL as well. In fact, MySQL is more compatible as compared to any other database with PHP language.

Feedback

We hope that you enjoyed this post about  “Define PHP” and also provide us valuable feedback as well as share your problem in Technical Forum.

 

MCQ Question


MCQ Question Php:-Hi Readers, In this blog, I will provide you most frequently asked interview question on PHP with an answer.I have already provided some question on PHP in the previous blog also.

MCQ Question Php

Here are some most asked MCQ Question Php:- 


Q1 what is the latest version of php language ?

A1- Latest Version of php language is PHP 7.0.2

Q2-How to write a string ‘Mcq’s question ‘ in php language?

A2-In php language,

<?php $string=’Mcq’s question’ ;   echo $string; ?>

Q3-How to unset a session variable in php?

A3- unset ($_SESSION[‘varname’]);

Q4-How to convert string variable to int in php language?


A4
-$string = ‘400’; $int = (int)$string;

Q5-How to check variable is string or not ?

A5-To check string variable type we use is_string($parameter) function.

Q6-How to define function in php language?

A6-
<?php
function Mcqs()
{
echo ‘Mcq’s Question on php’;

}

?>

Q7-How to define function with parameter in php language?

A7-

<?php
function Mcqs($param1,$param2,etc….)
{
echo ‘Mcq’s Question on php’;

}

?>

Q8-How to disclose a active connection in php?

A8-

<?php

mysql_close($conctionlink);

?>

Q9-Official website of Php language ?

A9-http://php.net/

Q10-How to make connection in php language?

A10-

 <?php  $conncetionlink = mysql_connect('localhost', 'mysql_user', 'mysql_password');  if (!$conncetionlink ) {     die('connection not established: ' . mysql_error());  } 
echo 'Congrtats ! Connected successfully';
 mysql_close($conncetionlink );  ?> 

Q11- How can we determine php variable is empty or not?

A11-To determine php variable is empty.we use

<?php $variable = 0; // Evaluates to true because $var is empty if (empty($variable))  {   
echo 'php function to check $variable is either 0, empty, or not set at all';  }  ?> 

Q12-To determine a php variable is SET or NOT then we use which function of php?

A12- We can determine a php variable is set or not by using following code.
<?php

$setvariable = '';

// This will evaluate to TRUE so
 the text will be printed.
if (isset($setvariable)) {
    echo "This variable  is set so 
I will print in this code.";
} ?>

Feedback

I hope you enjoyed this post about “MCQ’s Question Php” and provide your valuable feedback and share your problem in Technical Forum.

Even Odd number Program

Even Odd number Program in PHP

Even Odd number Program:- In this tutorial, I am going to explain how you can make a program to find a number is even or odd. Ever number are those which is divisible by 2 and odd numbers are not divisible by 2.

For Example, 20 is divisible by 2 so it is even number.

The main logic behind to find Even/ Odd of the given number is to first store the given number in a variable, say the number. Then divide the given number by 2 using (%) Modulus Operator, also known as Remainder Operator i.e., This Operator is used to find the Remainder of two numbers. For e.g. 10 % 4 = 2, 10 % 2= 0, 10 % 3 = 1, etc.

Using If Statements Check the number is divisible by 2, through Modulus Operator i.e if Remainder is 0 then number is completely divisible by 2 and Hence Echo or Print the Statement i.e the Given number is EVEN, Otherwise Print Given Number is ODD.

Even Odd number Program in PHP

<?php

$number=20;

if($num%2==0)
{
 echo "Even number"; 
}
else
{
 echo "Odd number";
} 

?>

Output of Even Odd number Program

	
Even Odd number Program in php
Even Odd number Program in php
Even Odd number Program in php
Even Odd number Program in php
Even Odd number Program in php
Even Odd number Program in php
Even Odd number Program in php
Even Odd number Program in php
Even Odd number Program in php
Even Odd number Program in php
Even Odd number Program in php

Even Odd number Program in php
Even Odd number Program in php
Even Odd number Program in php
Even Odd number Program in php
Even Odd number Program in php
Even Odd number Program in php
Even Odd number Program in php
Even Odd number Program in php
Even Odd number Program in php
Even Odd number Program in php
Even Odd number Program in php