Setup Cron Job In Windows Using Wamp/Xampp Server?

You have to follow below some very simple steps to run cron file in windows system.


1. Create a cron.php file (the code you want to execute at a regular interval)


2. Create a CRON.BAT file, copy and past the below code in the file
D:\xampp\php\php.exe  D:\xampp\htdocs\Application\cron.php


The path I have written is according to my xampp and cron.php file, update the path of files according to your system directory


3. To schedule a task

Click on start > All Programs > Accessories > System Tools > Scheduled Tasks

Or you can go directly
Control Panel > Scheduled Tasks

Right click in the folder
New > Schedule Task

Give appropriate name to the Task.
In the RUN text field… Type the complete path of the CRON.BAT file

in my case it is

Set the schedule of the job, you can use advanced button if required.

I hope this all will help you. Please leave your comment if you face any issue in setup cron job in windows 🙂

Generate unique n-digit random alphanumeric codes?


uniqid (prefix, more_entropy);


A unique website ID can be created in PHP using the uniqid () function.

This function has two parameters that can be set.



This is what will be appended to the beginning of each ID.



If this is false or not specified it will return 13 characters, if it is true then 23 characters will be returned.


Below are some examples:



/*creates a unique id with the ‘sa’ prefix*/
$a = uniqid(sa); echo $a; echo "<br />";

/*creates a longer unique id with the ‘sa’ prefix*/
$b = uniqid (sa, true); echo $b; echo "<br />";

/*creates a unique ID with a random number as a prefix – this is more secure than a static prefix*/
$c = uniqid (rand (),true); echo $c; echo "<br />";

/*this md5 encrypts the username from above, so its ready to be stored in your database*/
$md5c = md5($c); echo $md5c;



How to fix warning in transaction details api?

From last couple of days, I was struggling with an Transaction Details API.


The code I am working with is written in namespaces/blocks, so the problem I was facing is just like below.


SimpleXMLElement::__construct(): Entity: line 1: parser warning : xmlns: URI AnetApi/xml/v1/schema/AnetApiSchema.xsd is not absolute in /classes/anet_php_sdk/lib/AuthorizeNetTD.php on line 188



To get rid of these warning you have to follow some simple steps as below. I am assuming you are working with SDK Package, have downloaded by below URL.


You have to update some small changes in 2 files.

1. anet_php_sdk\lib\AuthorizeNetTD.php

2. anet_php_sdk\lib\shared\AuthorizeNetXMLResponse.php


In first step open file “AuthorizeNetTD.php”. Find method “_constructXml”, in this method replace first 2 lines



$string = ‘<‘.$request_type.’ xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd">’;
$this->_xml = @new SimpleXMLElement($string);



By below 3 lines of code



$string = ‘<‘.$request_type.’>’;
$this->_xml = @new SimpleXMLElement($string);
$this->_xml->addAttribute(‘xmlns’, ‘AnetApi/xml/v1/schema/AnetApiSchema.xsd’);



Now open “AuthorizeNetXMLResponse.php”. Copy/Paste the below method in the class.



/* @refer*/
private function removeResponseXMLNS($input)
// Remove XML response namespaces one by one
$input = str_replace(‘ xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd"’,”,$input);
$input = str_replace(‘ xmlns:xsi=""’,”,$input);
return str_replace(‘ xmlns:xsd=""’,”,$input);


Use this method in the constructor “__construct” of the class or replace this

[php]$this->xml = @simplexml_load_string($response);[/php]

By this

[php]$this->xml = @simplexml_load_string($this->removeResponseXMLNS($response));[/php]