This question is not about how to use CURL in PHP. But how to retrieve data that send using CURL with “-d” option. This command: curl -H ‘Content-Type: text/plain; charset=utf-8’ -d ‘Hello, World!’ -X POST http://localhost:8080 will produce empty array in $_POST variable. D…
Mock class with fluent interface in Phpunit
I am mocking this sample class with fluent methods that doesn’t have return type declaration: Using PhpUnit: By default, this will not work on fluent methods without return type declaration so I need to add the ff.: This works but cumbersome to write if there are a lot fluent methods. My question is, is…
How to implement various behaviour in PHP?
I have a site to which the administration uploads the code written with PHP which is saved in the database. The uploaded code must be launched on the site when opening a special page. Maybe there are some ideas how this can be implemented without eval()? Answer eval() can be used in such way if there are no s…
insert query mysql throws PDO::exec() expects exactly 1 parameter, 2 given
I’ve pieced together some code I’ve gleaned from the internet: I’m trying to scan a directory to insert file names and index into MariaDB table. My last hurdle it seems is this PDO error: PDO::exec() …
How to setup/access page in subdirectory of separate project for a Laravel/OctoberCMS website?
I have a website running an OctoberCMS theme that I built. It’s running on a server from DigitalOcean. I need to add a separate project (namely code from Matomo analytics) on the same server and access a public page (e.g. my_site.com/matomo). I’m new enough to Laravel and server configurations tha…
Allows decimal float numbers in WooCommerce form field type number
I am making an input form in WooCommerce using a function called woocommerce_form_field() for an input type number field like below: Now I would like to be able to allow decimal float numbers to be inputed in this field. Is it possible? What should I do? Answer You need to use ‘custom_attributes’ …
Slim Php not recognizing gets
I am just starting to work with Slim PHP. What could be the reason that get is not recognized on server? This route works: it returns required text https://mywebsite/back/public This route doesn’t …
Attempting something new in WP. Issue resetting WP loop
Im working in WP and basically what I’ve got set up is some logic to create a separate carousel for each category of my blog. For each carousel im displaying the top viewed posts for each category. Each Item in the carousel has a post thumbnail, author name and author avatar. My problem(if you scroll do…
How to render Html with smarty
I’m trying to render my raw HTML with smarty. The original text contains spaces and text returns, but when displayed, HTML is shown as plain text. Also, I tried to add {$brand.description|strip_tags:’UTF-8′} as a filter for my string. But it’s only deleting my HTML. How can my smarty t…
Change product status Woocommerce in short description field
I put product status and other info in short description field on wp all import for all products like this: avaliable I want if product category is Videocards to change product status and icon to “call” insted of “avaliable” like this: call Any way to do this with custom function in wp…