How to add pcntl Extensions for PHP in Linux systems

Source: Internet
Author: User
Tags ole pear

1. First look at the directory where the Phpize command is located (ps: my directory/usr/bin/phpize)
If not found, perform the installation

Yum Install Php53_devel (PS: Please note your version)

After the installation is complete. The Phpize command is generated

2, go to php.net download the corresponding version of the PHP source files
Let's take php-5.3.17 as an example, after decompression, into the corresponding module

CD Ext/pcntl
#先执行phpize
/usr/bin/phpize
./configure--with-php-config=/usr/bin/php-config (PS: Please specify the directory of the Php-config correctly)
#编译, installation
Make && make install

There was a mistake.

./configure compile OK, but make error
Error: ' Php_fe_end ' undeclared here (not in a function)

Workaround:

Source code error, enter php-5.3.17 directory
Sed-i ' s| php_fe_end| {null,null,null}| ' ./ext/**/*.c
Sed-i ' s| zend_mod_end| {null,null,null}| ' ./ext/**/*.c

Re-make && make install

3. A pcntl.so file is generated when the compilation is complete. In the Model directory of PHP

Edit/etc/php.ini, join

Extension=pcntl.so

4. Restart Apache

Service httpd Restart

5. Test whether the installation is successful

<?php
Echo Pcntl_fork ();
?>

Output: 23165

PHP Code:
/**
* Export File
* @return String
*/
Public Function Export ()
{
$file _name = "Transcript-". Date ("Y-m-d h:i:s", Time ());
$file _suffix = "xls";
Header ("Content-type:application/vnd.ms-excel");
Header ("content-disposition:attachment; Filename= $file _name. $file _suffix ");
According to the business, you do the template assignment.
$this->display ();
}

HTML code:

xmlns:x= "Urn:schemas-microsoft-com:office:excel"
xmlns= "HTTP://WWW.W3.ORG/TR/REC-HTML40" >
<meta http-equiv=content-type content= "text/html; Charset=utf-8 ">
<meta Name=progid content=excel.sheet>
<meta name=generator content= "Microsoft Excel One" >
<body>
<table border=1 cellpadding=0 cellspacing=0 width= "100%" >
<tr>
&LT;TD colspan= "5" align= "Center" >
</td>
</tr>
<tr>
&LT;TD style= ' width:54pt ' align= "center" > Numbering </td>
&LT;TD style= ' width:54pt ' align= "center" > Name </td>
&LT;TD style= ' width:54pt ' align= "center" > Language </td>
&LT;TD style= ' width:54pt ' align= "center" > Math </td>
&LT;TD style= ' width:54pt ' align= "center" > English </td>
</tr>
<tr>
&LT;TD align= "center" >1</td>
&LT;TD style= "" align= "center" >Jone</td>
&LT;TD style= "" align= "center" >90</td>
&LT;TD style= "" align= "center" >85</td>
&LT;TD style= "" align= "center" >100</td>
</tr>
<tr>
&LT;TD align= "center" >2</td>
&LT;TD style= "" align= "center" >Tom</td>
&LT;TD style= "" align= "center" >99</td>
&LT;TD style= "" align= "center" >85</td>
&LT;TD style= "" align= "center" >80</td>
</tr>
</table>
</body>

Let's look at a more convenient component

Here you need to use the Pear two packages Spreadsheet Excel Writer and OLE if there are no separate from http://pear.php.net/package/Spreadsheet_Excel_Writer/and http://pear.php.net/package/OLE/download, unzip and put in the Pear directory.

The full code is as follows:

<?php
Include ' writer.php ';
/* * * * * ready to export Data * * * *
$head = ' one Week Schedule ';
$data = Array (' Monday ' = = Array (' time ' = ' = ', ' event ' = ' Company regular meeting '), Array (' time ' = ' + ', ' even T ' = ' Department meetings '),
The ' Tuesday ' + array (' time ' = ' 09:30 ', ' event ' + ' and ' Mr. Stinsen Breakfast '),
' Wednesday ' = = Array (' time ' = ' 12:10 ', ' event ' = ' Market mid-order report '), Array (' time ' = ' 15:30 ', ' event ' = ' Market (Strategic deployment Meeting ')),
' Thursday ' = = Array (' time ' = ' = ', ' event ' = ') '),
' Friday ' = = Array (' time ' = ' 16:00 ', ' event ' = ' WoC ' Stock Seminar '), Array (' time ' = ' = ' 17:00 ', ' event ' =&gt ; ' Fly to Wall Street '), Array (' time ' = ' 21:00 ', ' event ' = ' Meet Clinton '))
);
/* *** *** */
$workbook = new Spreadsheet_excel_writer ();
$filename = Date (' Ymdhis '). XLS ';//csv
$workbook->send ($filename); Send Excel file name for download
$workbook->setversion (8);
$sheet = & $workbook->addworksheet ("Sheet1"); Create a worksheet
$sheet->setinputencoding (' utf-8 '); Character
$headFormat = & $workbook->addformat (Array (' Size ' = +, ' Align ' = ' center ', ' Color ' = ' white ', ' fgcolor ' = = ' brown ', ' Bold ' = ' 1 ', ' Border ' = ' 1 ');//define the format
$dayFormat = & $workbook->addformat (Array (' Size ' = +, ' Align ' + ' center ', ' valign ' = ' vcenter ', ' Fgcol or ' = ' green ', ' Color ' = ' white ', ' Border ' = ' 1 ');//define the format
$dataFormat = & $workbook->addformat (Array (' Size ' = +, ' Align ' = ' left ', ' Border ' = ' 1 ', ' Color ' = = ' Black ', ' fgcolor ' = ' cyan ');//define the format
$sheet->setcolumn (0, 0, 20); Set width
$sheet->setcolumn (1, 1, 15); Set width
$sheet->setcolumn (2, 2, 30); Set width
$r = 0;
$sheet->write (0, $r, $head, $headFormat); Table title
$sheet->mergecells (0, 0, 0, 2); Cross-column display
$r + +; Data starts from line 2nd
foreach ($data as $day = = $events) {
$c = 0;
$sheet->write ($r, $c, $day, $dayFormat);
if (! $events) {
No plans for the day
$r + +;
} else {
$startRow = $r;
foreach ($events as $e) {
$c = 1;
$sheet->write ($r, $c + +, $e [' time '], $dataFormat); Worksheet Write Data
$sheet->write ($r, $c + +, $e [' event '], $dataFormat); Worksheet Write Data
$r + +;
}
Merging $day cells
$sheet->mergecells ($startRow, 0, $r-1, 0);
}
}
$workbook->close (); Complete the download
?>

How to add pcntl Extensions for PHP in Linux systems

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.