Skip to content

Tag: php

How to create PDO connection in __construct()?

I have one class that is containing three methods. All of those methods need to database, Then I want to create a system for connection to database before everything. Something like this: Now I want to know (in first) what I did is a standard approach? and (in second) how can I check [if connection was discon…

Using imagejpeg() function to save image file

I am trying to upload the picture into two different directories and I would like to use the imagejpeg() function to put the picture in one of the directories. The two directories are called uploads and resized. Here is my code to accomplish this: However, I keep getting the error imagejpeg() expects paramete…

How to replace custom html tag with html code in php

This is my scenario: In a custom CMS developed in PHP, I need to parse HTML string searching some custom tags to replace them with some HTML code. Here is an example for clarifying: I need to find the custom tags and replace them with the template of the item, as a result: This would be very helpful, but I

Laravel `array_pluck` on any key

Is possible use something like array_pluck($array, ‘users.*.id’)? Imagine that I have: And I want get [1, 2, 3]. I tried something like: users.*.id, users.id and users..id, but nothing worked. Answer From Laravel 5.7, you may use the Arr::pluck() helper. Use array_pluck($array[‘users’]…

How to disable recaptcha?

Obsolite, Old question was like: Is there a way to turn off the recaptcha, created using noscript? I used the standard example, but now I have to make it disappear for certain IPs. I know how to get the ip, but I have not figured out how to turn recaptcha off. I have a wild idea to use php(html) to