php get current date

You can get current date in php using getdate().This function return array of options like seconds,minutes,hours,mday, and other options.You can also get date uing date function of php.Here i am presnting you some examples how to get current date in php. $dateArray=getdate();     echo “Current seconds=”.$dateArray[‘seconds’];    echo “Current minutes=”.$dateArray[‘minutes’];    echo “Current hours=”.$dateArray[‘hours’];    echo “Current mday=”.$dateArray[‘mday’];    echo “Current wday=”.$dateArray[‘wday’];    echo “Current

Read more

php get current timestamp

There is lots of way to get current timestamp. In php you can get current unix timestamp using time() function.Please use bellow given examples to get current unix timestamp. date_default_timezone_set(‘Asia/Calcutta’); //optional If PHP 5.3 generate Wornings then use it $cureentTimeStamp=time(); //current timestamp echo $cureentTimeStamp; echo ‘another Way’; echo strtotime(“now”);

Read more

PHP Download File Forcefully

In php there are some situation where you want to download file Forcefully.For that you have to use php header function. In header function you have to use Content-Type as application/octet-stream and Content-Disposition. ob_clean(); ob_start(); $filename=’private_movie.zip’; $absoluteFilePath=’/public_html/downloads/private_movie.zip’ header(“Pragma: public”); header (“Cache-Control: must-revalidate, post-check=0, pre-check=0”); header(“Cache-Control: maxage=1”); header (“Content-Type: application/octet-stream”); header (“Content-Length: ” . filesize($absoluteFilePath)); header (“Content-Disposition: attachment; filename=$filename”); readfile($absoluteFilePath);

Read more

IIF in php

There is ternary operator(conditional) operator in php which is used for IIF equivalent condition in php. The conditional operator is the “?:” (or ternary) operator. The expression (expr1) ? (expr2) : (expr3) evaluates to expr2 if expr1 evaluates to TRUE, and expr3 if expr1 evaluates to FALSE. Since PHP 5.3, it is possible to leave out the middle part of

Read more

Php upload file using web service soap

In php file upload can be done easily if you know the logic of file system.What we need to do is create simple nusoap server that have method of two parameters.one parameter is for file name and one parameter is for base64 encoded string of file contents. when client make request it must have to pass file as base64 encoded

Read more

php convert array to query string

Now you can eaisly convert an array to query string in php.No need to do any code for that php has inbuilt function for converting array into query string.If you are using php 5 then you can use inbuilt function of php called “http_build_query()”. http_build_query() : Defination : string  http_build_query ( mixed $query_data [, string $numeric_prefix [, string $arg_separator [, int

Read more

Web Service Authentication php

Using nusoap web service you can easily authenticate user for web service access.You can use setCredentials method of client to pass username and password,The given password will be checked against the web service access. $client->setCredentials($username,$password,”basic”); You can find the working demo here and you can also download the scripts. Client : 1)In line no 48 change “http://127.0.0.1:80/webservice_file_transfer/nusoap/server/server.php?wsdl” to your corresponding url

Read more

php array to file

Now you can easily store multidimensional array into file.There is some sitution when you need to store multidimensional array into file.For example you want to debug some output (Example IPN).There is no way to debug ipn so you want to write post variable or other variable to file then you can store this array to file directly. $yourArry=array( ‘0’=>’test1′, ‘1’=>’test2′, ‘2’=>array( ‘0’=>’test1′, ‘1’=>’test2′,

Read more
1 2