I own a high traffic website that does business in the USA and Canada. We have lots of servers but I want to make sure it's 100% available with no latency whatsoever.
I've learned about creating custom extensions (I know a little C) and I want to create custom validation/files (since php extensions runs faster).
I don't want to ask for all new extensions from you guys but I want to know the general idea on how to build it (I am using CentOS).
Example:
One section of our site is the shipping tracking and this require a postal code.
For the USA I have:
function check_usa_postal_code($pc) {
return is_numeric($pc);
}
But for Canada, I would like to build in PHP a custom function like:
check_canada_postal_code($pc)
This function should return 1 or 0.
Thanks
You should also consider using Zephir. Its syntax is very similar to PHP. It is specially designed to create PHP extensions and compiles into an extension.
There are even several converters from regular PHP to Zephir. They do not take into account all the peculiarities, so some minor code changes will be needed before compiling. I use sandrokeil/php-to-zephir.
I recommend to read this article:
Extension Writing Part I: Introduction to PHP and Zend
and here's how to compile:
UNIX: Compiling PHP Extensions
Build PHP extensions with SWIG
(I recommend SWIG like mario said)
Read more on Canadian zip codes at Postal codes in Canada since not all letters are being used.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With