Correct php code for seeing the IP Address of the Server

Archive for the ‘Php’ Category
  • Correct php code for seeing the IP Address of the Server

    Posted by PRIYAQPT on April 18th, 2012 at 7:59 am
    You can check your ip address for your machine by using the following code: echo $_SERVER['REMOTE_ADDR']; If you wanted to check whether the IP address got changed then try with the below statement. echo $_SERVER['SERVER_ADDR']; And, it was showing the new ip address. But below statement is still showing the old ip address. echo file_get_contents("whatismyip.com") So, If you would like to know whether $_SERVER['SERVER_ADDR'] is the correct way of knowing the IP address of t...
    Read More
  • How to enable PHP cURL in windows

    Posted by PRIYAQPT on April 12th, 2012 at 9:17 am
    PHP has build-in extension for getting content from remote sites. This extension is known as cURL. For enabling cURL in windows environment, we need to do below two steps. -Uncomment extension=php_curl.dll in the PHP.INI file. -Copy the below two dll files from PHP folder and put it under windows/system32 dir. ssleay32.dll libeay32.dll...
    Read More
  • PHP cURL and its uses

    Posted by PRIYAQPT on March 29th, 2012 at 5:55 am
    cURL which  plays an important role in automating the tasks involving interaction between many web sites. cURL (Client for URLs) is free and open software that compiles and runs under a wide variety of operating systems. It is available as  cURL command line tool or as libcurl library. It is useful to transfer data from or to a server, using one of the supported protocols (HTTP, HTTPS, FTP, FTPS, SCP, SFTP, TFTP, DICT, TELNET, LDAP or FILE) cURL offers lot of useful tricks like p...
    Read More
  • Code for getting WordPress logged user from external php file

    Posted by PRIYAQPT on March 26th, 2012 at 5:29 am
    We have used a Session variable for getting the Wordpress logged in user id from an external php file. But it didn't work once after upgrading the wordpress. Obviously the session variable setting page was overwritten by new wordpress update. So, we have decided to use the wordpress object to get the userid instead of session variable so that any future wordpress update won't affect our code. We have used below piece of code in the external php file, and it was working fine. [php] ...
    Read More
  • PHP string captialization

    Posted by PRIYAQPT on March 13th, 2012 at 8:17 am
    Php has 3 primary captialization function strtoupper strtolower ucwords Converting the String to upper case- strtoupper() strtoupper () converts the string to upper case string For eg: [php] <?php echo "oldstring: ".$string="hello". "<br/>"; echo "newstring: ".$newstring=strtoupper($string); ?> [/php] OUTPUT: oldstring: hello newstring: HELLO Converting the String to lower case- strtolower() strtolower() co...
    Read More
  • PHP die()

    Posted by PRIYAQPT on March 13th, 2012 at 7:47 am
    Basically error handling is very simple in php. While writing the code for your applications  you might struggle to find out the errors . In  that case you can use die() to handle errors. Let us consider the following example: [php] <?php $file=fopen("sample.txt","r"); ?> [/php] If the file does not exist you will be getting an error like this: OUTPUT: Warning: fopen(sample.txt) [function.fopen]: failed to open stream: No such file or directory in C:\ww...
    Read More
  • gettype() in php

    Posted by PRIYAQPT on March 12th, 2012 at 9:32 am
    Like other programming languages, php does not requires any  variable declaration so we can move freely with php datatypes. To view the datatype of the variable  use  gettype() function Eg1: [php] <?php $name="HELLO"; echo "Name:".$name; echo "<br/>"; echo "Datatype:".gettype($name); ?> [/php] OUTPUT 1: Name:HELLO Datatype:string Eg 2: [php] <?php $value=25; echo "Value:".$value; echo "<...
    Read More
  • Generating a captcha code using PHP

    Posted by pradeepqpt on November 25th, 2011 at 11:10 am
    This script generates images (known as "Captcha's") which contain security codes used for protecting a form from spam bots. By encoding a 'password' inside an image and asking the user to re-enter what they see you can verify the user is a human and not automated software submitting your form. code for captcha script <?php session_start(); /** File: CaptchaSecurityImages.php*/ class CaptchaSecurityImages { var $font = 'monofont.ttf'; function generateCode($characters)...
    Read More
  • print_r() Versus var_dump()

    Posted by pradeepqpt on November 22nd, 2011 at 10:41 am
    There are many functions available in PHP to debug a variable. This function can be used to store value in an array or other another object and it is important to troubleshoot the codes. Let us see some of them such as var_dump(), print_r() and var_export(). Using the var_dump function you can display the structured information about the variables and expression along with its type and value. Arrays can be explored recursively with intended values to show the structure. print_r() displa...
    Read More
  • Page Redirection in php

    Posted by pradeepqpt on September 21st, 2011 at 7:07 am
    When we want to move from one page to another we have to use page redirection here is a php code that deals with page redirection .Page redirection can be done in php page .sing header() which is used to send a raw HTTP header. (i-e) header("Location:newpage.php"); will load the newpage.php. Note that header() must be used before sending any output either by HTML tags, blank lines or from PHP. Otherwise error message "header already sent" will be shown. In this situation, we can use jav...
    Read More
Page 1 of 612345...Last »
Categories
Archives
Recent Posts
Meta
rss facebook linkedin reddit subscribe

Developed by QualityPoint Technologies

Tech Blog   Bookmarking   Quotes   QTP Book   The Christmas   Time Sheet   Learn webdevelopment