Category : "PHP"

Php tutorials

3 ways to serialize variables in php

The idea behind serializing a variable is to create a storable string format of it, such that the same variable can be recreated later when required using the string. 1. serialize and unserialize These are the traditional functions to serialize and unserialize data in PHP. $a = array('a' => 'Apple' ,'b' => 'banana' , 'c' => 'Coconut'); //serialize the array $s = serialize($a); echo $s; //a:3:{s:1:"a";s:5:"Apple";s:1:"b";s:6:"banana";s:1:"c";s:7:"Coconut";} echo '<br ...

PHP : Add Login with Github to your website

Github Login Github has become a very popular social login on websites related to programming and development. Github itself is a big storehouse of opensource projects and community of developers. Github oAuth documentation can be found at http://developer.github.com/v3/oauth/. Register website with Github oAuth The first thing to do would be to register your website with github. Login into your github account, go to settings ...

Add Login with Yahoo to your php website

Yahoo OpenId In the previous article, we learned how to integrate . Its good to know that Yahoo is also an openid provider and "Login with Yahoo" can be added to a website in a very similar manner. Yahoo's openid discovery url is http://me.yahoo.com/. The rest of the code is very simple. Code <?php /* The following code example demonstrates, how to implement "Login with ...

Php code for login with google using openid

OpenId A very popular login method now a days is to allow users to login through their google, openid etc accounts. One popular protocol being used is the OpenId. According to wikipedia : OpenID is an open standard that describes how users can be authenticated in a decentralized manner, eliminating the need for services to provide their own ad hoc systems and ...

Run php code online

phpscribble.com is the new tool to run and play with php code online. Can be used to test small php code quickly and effectively, without the need to install anything. Runs off the browser, but does need an internet connection. Features 1. Runs code on Php 5.4+ 2. Supports most extensions and functions. (Like curl, gd, sqlite etc) 3. Allows html output and interactive ...

Use clientside ssl certificate with curl and php

Clientside certificates are often used in soap webservices. For example the wsdl file link might require a clientside certificate. The server throws an error like this : HTTP Error 403.7 - Forbidden: SSL client certificate is required. Curl Command To use clientside certificate with curl , test the following command curl --cert certificate_file.pem https://www.example.com/some_protected_page or curl --cert certificate_file.pem:password https://www.example.com/some_protected_page The above command should fetch the protected page ...

10+ tips to localise your php application

Localisation Localisation involves changing various parts of application output like display of dates , time , numbers , language etc according to the standards of the geographical region of a user. Localisation is an important feature of applications that targets users across the globe and not just one region. So here are a set of simple tips and techniques every php application ...

40+ Useful Php tips for beginners – Part 3

Part 2 26. Avoid direct SQL query , abstract it $query = "INSERT INTO users(name , email , address , phone) VALUES('$name' , '$email' , '$address' , '$phone')"; $db->query($query); //call to mysqli_query() The above is the simplest way way of writing sql queries and interacting with databases for operations like INSERT, UPDATE, DELETE etc. But it has few drawbacks like: All values have to be ...

40+ Useful Php tips for beginners – Part 2

Part 1 11. Do not gzip output in your application , make apache do that Thinking of using ob_gzhandler ? No dont do that. It doesnt make sense. Php is supposed to write your application. Dont worry about how to optimise data transfer between server and browser inside Php. Use apache mod_gzip/mod_deflate to compress content via the .htaccess file. 12. Use json_encode when echoing ...

15+ tips to secure your php application

Php is used to write web applications which are online and publicly accessible. Therefore security is a fundamental necessity of these applications to keep the data safe and free from unauthorized access. Below are a bunch of simple tips/hacks/ideas to design your php applications to have better security. The Code 1. Avoid short tags If they are disabled on some server , then all ...



Connect with us