Error 500: Premature end of script headers

It was a file permission issue. All files on my website were set to a permission level of ‘644.’ Once I changed the permission level to 705 (chmod 705) everything worked. Note that I changed it to 705, but 755 will also work. I also changed the folder it was in to 701 (to hide … Read more

Is there an equivalent in C++ of PHP’s explode() function? [duplicate]

Here’s a simple example implementation: #include <string> #include <vector> #include <sstream> #include <utility> std::vector<std::string> explode(std::string const & s, char delim) { std::vector<std::string> result; std::istringstream iss(s); for (std::string token; std::getline(iss, token, delim); ) { result.push_back(std::move(token)); } return result; } Usage: auto v = explode(“hello world foo bar”, ‘ ‘); Note: @Jerry’s idea of writing to an … Read more

How do you log all API calls using Guzzle 6

You can use any logger which implements PSR-3 interface with Guzzle 6 I used Monolog as logger and builtin middleware of Guzzle with MessageFormatter in below example. use GuzzleHttp\HandlerStack; use GuzzleHttp\Middleware; use GuzzleHttp\MessageFormatter; use Monolog\Logger; $stack = HandlerStack::create(); $stack->push( Middleware::log( new Logger(‘Logger’), new MessageFormatter(‘{req_body} – {res_body}’) ) ); $client = new \GuzzleHttp\Client( [ ‘base_uri’ => … Read more

phpmysql error – #1273 – #1273 – Unknown collation: ‘utf8mb4_general_ci’

This solution worked for me 1) Click the “Export” tab for the database 2) Click the “Custom” radio button 3) Go the section titled “Format-specific options” and change the dropdown for “Database system or older MySQL server to maximize output compatibility with:” from NONE to MYSQL40. 4) Scroll to the bottom and click “GO”. If … Read more

PHP Echo text Color

How about writing out some escape sequences? echo “\033[01;31m Request has been sent. Please wait for my reply! \033[0m”; Won’t work through browser though, only from console ;))

Best Way To Autoload Classes In PHP

Please, if you need to autoload classes – use the namespaces and class names conventions with SPL autoload, it will save your time for refactoring. And of course, you will need to instantiate every class as an object. Thank you. Like in this thread: PHP Autoloading in Namespaces But if you want a complex workaround, … Read more

How can I create custom SEO-friendly URLs in OpenCart?

It turns out this can be done with a relatively simple change to a single file. No .htaccess rewrite rules, simply patch the catalog/controller/common/seo_url.php file and add your pretty URLs to an existing database table. The patch to seo_url.php: Index: catalog/controller/common/seo_url.php =================================================================== — catalog/controller/common/seo_url.php (old) +++ catalog/controller/common/seo_url.php (new) @@ -48,7 +42,12 @@ $this->request->get[‘route’] = ‘product/manufacturer/product’; … Read more

How can I create custom SEO-friendly URLs in OpenCart?

It turns out this can be done with a relatively simple change to a single file. No .htaccess rewrite rules, simply patch the catalog/controller/common/seo_url.php file and add your pretty URLs to an existing database table. The patch to seo_url.php: Index: catalog/controller/common/seo_url.php =================================================================== — catalog/controller/common/seo_url.php (old) +++ catalog/controller/common/seo_url.php (new) @@ -48,7 +42,12 @@ $this->request->get[‘route’] = ‘product/manufacturer/product’; … Read more

PHP, pass array through POST

Edit If you are asking about security, see my addendum at the bottom Edit PHP has a serialize function provided for this specific purpose. Pass it an array, and it will give you a string representation of it. When you want to convert it back to an array, you just use the unserialize function. $data … Read more