Blog Archives

Code for getting WordPress logged user from external php file

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.

Posted in Php Tagged with:

PHP string captialization

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: OUTPUT: oldstring: hello newstring: HELLO Converting the String to lower case- strtolower() strtolower()

Posted in Php Tagged with: ,

PHP die()

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:

Posted in Php Tagged with: ,

gettype() in php

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: OUTPUT 1: Name:HELLO Datatype:string Eg 2: OUTPUT 2 : Value:25

Posted in Php Tagged with: ,