Category Archives: Core PHP

How to integrate PayPal in your PHP website?

You are not aware of the PayPal payment gateway, and you need to integrate PayPal into your PHP website; then this tutorial will help you with how to integrate PayPal into the PHP website. No need to work with the hard code; just simply follow the below steps, and you can get PayPal working in your PHP website.

Step 1)

Click Here for download the PayPal standard code for PHP.

Step 2)

If you need to work with the live account, then set the below URL in your form action.

https://www.paypal.com

If you need to work with the sandbox account, then set the below URL in your form action.

https://www.sandbox.paypal.com/cgi-bin/webscr

Step 3)

Now you need to set your PayPal email to the business input fields.

Also set the notify URL, return URL, and cancel URL of your website. where the page will redirect after the action call.

Step 4)

When you follow the above steps successfully, then you can get PayPal working in your PHP website.

Convert HTML to Ms Word Using Php Script

In this tutorial, you can learn about how to convert text or export HTML to Microsoft Word file format by using PHP programming. If you develop any web application, and in that application, you want to add one feature, like you want to create a Word document from your PHP web application, then at that time you can use this PHP tutorial script for exporting HTML text to Microsoft Word. You can also format the word file from HTML code by putting a simple HTML tag, and you can also use an inline style sheet to change the color, increase the font size, etc.

Step 1)

Create a new PHP file like “example.php” and put the below code inside that file with PHP starting and ending code.

header(“Content-type: application/vnd.ms-word”);

header(“Content-Disposition: attachment; Filename=SaveAsWordDoc.doc”);

$html = "<meta charset="utf-8">
<title>A simple, clean, and responsive HTML export to Ms Word</title>
<style>body {height: 297mm;width: 210mm;margin: 0 auto;font-size: 10pt;line-height: 10pt;font-family:  Times New Roman, Arial, sans-serif;color: #000;}</style>
<form>
<table style="width:210mm;" width="100%" cellspacing="0" cellpadding="5" border="0">
<tbody>
<tr>
<td>REF No: 123456</td>
</tr>
<tr>
<td><strong>Date: 24 October 2019 </strong></td>
</tr>
<tr>
<td>Dear USER NAME</td>
</tr>
<tr>
<td></td>
</tr>
<tr>
<td>
<table width="100%" cellspacing="0" cellpadding="5" border="0">
<tbody>
<tr>
<td width="30">
<div style="border: solid 1px #000; margin: 2pt; float: left;">&amp;</div></td>
<td>USER data.</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</form>";
echo $html;

Step 2)

Now you can run this file in your browser. You can get your HTML or text in an MS Word file. This will be supported in each and every browser.

How to Work Mpdf Workable in Php 7 ?

If you use an old version of PHP in your local system and you integrate the mpdf in that old version. After you change your PHP version to the latest version and mPDF is not working, then simply follow our below steps, and you will get the mPDF working in your latest PHP version.

Step 1)

Click here to download the mPDF.

Step 2)

Include the mPDF.

require_once _DIR_ . ‘/MPDF/vendor/autoload.php’;

Instead of

require_once( ‘mpdf/mpdf.php’);

Step 3)

Just change your code to

$html = "Your html code here";
$mpdf = new \Mpdf\Mpdf(['mode' => 'utf-8', 'format' => 'A4','0','',0,0,0,0,'margin_header' => 0,'orientation' => 'P']);
$mpdf->setAutoTopMargin = 'stretch';
$mpdf->setAutoBottomMargin = 'stretch';
$mpdf->WriteHTML($html);
$mpdf->Output();
exit;

Instead of

$html = "Your html code here";
$mpdf=new mPDF('utf-8', 'A4', 0, '', 0, 0, 0, 0, 0, 'P');
$mpdf->setAutoTopMargin = 'stretch';
$mpdf->setAutoBottomMargin = 'stretch';
$mpdf->WriteHTML($stylesheet, 1);
$mpdf->WriteHTML($html);
$mpdf->Output();

Step 4)

Now your mPDF is working in PHP 7 and above versions.