Find IP address by PHP

Hello

I am finding IP address by PHP.  I just used a variable $ip address & use server variable $_SERVER[‘REMOTE_ADDR’] where story the user ip address. The code in below-

<?php

$ip=$_SERVER[‘REMOTE_ADDR’];
echo ‘<h1>Your IP address is: ‘.$ip.'</h1>’;

?>

Show Live Demo Plz click HERE.

Thanks-

Use here doc in php…

Hello Friends, how are you?

I am showing now, how to use “here doc” in php? So, consider the below code-

 

<?php

//here is two variable

$username=”tisuchi”;

$password=”1234”;

 

//here doc is starting…

echo <<< my_login_start()

User Name: $username

Password: $password

my_login_start();

?>

 

Explain:

First I take two variable $username and $password. Then I make a echo statement, here I use a function (like variable) my_login_start(). Then I print User Name and Password accordingly variable $username & $passsword and finally I close my_login_start();. Now, It is ok.

 

 

Output:

User Name: tisuchi

Password: 1234

Print php variable and string…

Hello Friends, how are you?

I am showing now, how to print variable and string at a time in php? So, consider the below code-

<?php

//this is variable

$name=”Thouhedul Islam Suchi”;

 

echo “Hello, “. $name.”. Thank you for visiting my site.”;

?>

 

Explain:

First I take a variable $name where I put my name. I just want to print this name with other text. Then I make echo statement. After finishing “Hello, ”, I didn’t close my statement by using  ;. After that, I use a . which call concatenation sign for adding with variable and string. Then I put my variable. After putting variable, I put concatenation sign again to add string with variable. Finally I close my echo statement by using ; sign.

 

 

 

Output:

Hello, Thouhedul Islam Suchi. Thank you for visiting my site.

PHP information Check…

Hello friends, how are you?

Hope you are well. I am just show you, about the print of PHP and server information. Here I work in localhost.

Write this code in php editor.

<?php

echo phpinfo();

?>

Details:

Here I used a phpinfo() function which will show the php and localhost server details.

Then browse this file by browser. Then you will able to look all the information about server and php.

Thanks for reading….