Re: Dynamic Properties in PHP 8.2 Programming Web Development by Dani …$temp_obj->foo = 'bar'; $temp_obj->baz = 'bat'; // Create a PHP array with 2 elements $temp_arr = array( 'foo' => 'bar'; 'baz…' => 'bat'; ); // Convert a PHP array to a PHP object $temp_obj = json_decode(json_encode($temp_arr)); This obviously does not… Re: Dynamic Properties in PHP 8.2 Programming Web Development by jkon I can't get it , why anyone would want to `$user = new User(); $user->nickname = 'Dani';` if nickname is not a public property of User , or even worse `$user = new stdClass(); $user->nickname = 'Dani';` ? Why ? Re: Dynamic Properties in PHP 8.2 Programming Web Development by Dani > This obviously does not make sense to do if you want to create or work with a User object or something of that sort. I realize that in my previous post I incorrectly gave the example of `$user = new stdClass(); $user->nickname = 'Dani';`. My intention was not to say that it was good coding practice to represent a user of the app with an … Safely upload a file Programming Web Development by Dani Here's a quick bit of code to upload a file in PHP. Re: How to show visa info based on country selection in a travel form? Programming Web Development by Biiim … in my example an ajax request to a PHP page, my advice on that would be to…logic it follows before it dies. My favourite for php is `var_dump($var);` and in javascript use `console…({ method: "POST", url: "https://example.com/myajaxrequest.php", data: { var1: 'test', var2: 'something'} }).done(function( … Re: Safely upload a file Programming Web Development by Dani I realize I could have done better when coming up with a safe name. As it stands, a file uploaded that has a file name in non-Latin characters will just end up with a bunch of underscores. I’m not even sure if that suffices as a file name, but for sure there will be collisions as multiple files are attempting to be saved with the same _ name. Re: Flood control using Redis Programming Web Development by Dani Status update: we now use Cloudflare’s free rate limiting functionality. Back when I wrote this, Cloudflare charged for rate limiting. Note we have a Business account. Dynamic Properties in PHP 8.2 Programming Web Development by Dani …explicitly declaring it first in the class. If you do, PHP throws a warning like: Creation of dynamic property SomeClass::$foo…If nickname wasn’t already declared in the User class, PHP used to just shrug and let it slide. Not anymore…until it stops working as well. (DaniWeb is currently on PHP 8.3.8 and it's still working.) Hope this… Re: Dynamic Properties in PHP 8.2 Programming Web Development by Dani Oh, and an important bit I forgot to mention: PHP's built-in stdClass has the `#[AllowDynamicProperties]` attribute already added. … fact, you can see in the [PHP docs](https://www.php.net/manual/en/class.stdclass.php) that the definition of the stdClass… Re: My php is showing wrong results of time difference Programming Web Development by Dani … = $_POST['start']; $end = $_POST['end']; // Create DateTime objects in PHP for us to work with $start_object = date_create($start); $end_object = date_create…($end); // Get the difference represented as a PHP object $diff = date_diff($start, $end); // $diff is now a… Re: My php is showing wrong results of time difference Programming Web Development by Dani …;h` (All properties available [here](https://www.php.net/manual/en/class.dateinterval.php), but if you want to calculate a runner… Re: How to connect to the Pinterest API using PHP? Programming Web Development by geekinformatic Hey! If you're using the CakePHP framework, you can connect to the Pinterest API with cURL and OAuth integration. Just follow Pinterest’s API docs for endpoints and token handling. Re: How do I remove the last character without breaking the string? Programming Web Development by MAY_261 …, $length - 1, 'UTF-8'); echo $new_text; https://flatcoding.com/tutorials/php/php-remove-last-character-from-string/ This code removes the last… Re: How do I remove the last character without breaking the string? Programming Web Development by Montasser_1 …, 'UTF-8'); > echo $new_text; > https://flatcoding.com/tutorials/php/php-remove-last-character-from-string/ > This code removes the… How do I remove the last character without breaking the string? Programming Web Development by Montasser_1 I try to remove the last character from a string with Japanese text and emojis using this code: <?php $text = "私の名前はダバーです👩‍🚀"; $new_text = substr($text, 0, strlen($text) - 1); echo $new_text; The output breaks the characters and shows garbage. How do I fix this? My php is showing wrong results of time difference Programming Web Development by Mr.M Hi DW, I'm trying to mark attendance register which has the date for which that register is being marked for as well as the date which the register is actually marked on. For Date as well as Marked Date. I also have two time picker textboxs which one is for time in and the other is for time out. Now I've been trying to use even time diff … Re: My php is showing wrong results of time difference Programming Web Development by Mr.M Thanks, to clarify what I meant regarding the dates is that I have a date input that shows a calendar when a user click on it to choose the date for which the register is being marked for. Then I also have 2 time inputs one is for timein and the other is for timeout. Let me try your code and see if it does solve the problem I've been having.… Re: My php is showing wrong results of time difference Programming Web Development by Mr.M I'm getting an error saying the `date_create` class can not be found Re: My php is showing wrong results of time difference Programming Web Development by Dani Oh goodness, I’m sorry! I made a typo. Remove the new keyword. I’ve edited my post above. Re: My php is showing wrong results of time difference Programming Web Development by Mr.M Thank you, you saved me, I've been trying for weeks now. It works now perfectly with your code. Re: My php is showing wrong results of time difference Programming Web Development by Dani > Also just one more question regarding your code, I will have to minus 1 hour from the total hour difference, do I have to use the %h - 1? Just in case you haven't figured this out yet, the answer is no :) In my code above, see where I am showing you what $diff looks like on line 15? You should be able to do something like this: $… Re: My php is showing wrong results of time difference Programming Web Development by Erussuhsh Hi I'm new to android app development can you teach me how to make a app Re: My php is showing wrong results of time difference Programming Web Development by Dani I don’t personally know Android development or mobile development at all. However, others here might. Please start a new question [by clicking here](https://www.daniweb.com/community/contribute/181). Re: Optimizing working with big data Programming Software Development by ThinkWriteGrow … datasets? > > I am tagging this topic both with php (because that is my language of choice, and the one… Re: How to show visa info based on country selection in a travel form? Programming Web Development by Dani … please provide the Javascript code as well as PHP code that is buggy so that we can …is most likely because of a bug in the PHP code. If the DOM doesn't reflect the…would store them in some form of database that PHP would have access to, and pass back ot javascript… javascript, and yet using AJAX to have the PHP check a list. Do you mean the country-… How to show visa info based on country selection in a travel form? Programming Web Development by eservices …;select> dropdown and send that to a PHP file via AJAX. The PHP checks a list and responds with JSON. But…: Avoids links and commercial terms Focuses on technical workflow (AJAX, PHP, JSON) Mentions *<link removed by moderator>* as an… Re: How to show visa info based on country selection in a travel form? Programming Web Development by groverharleen Hello, please use developer tool while working on HTML/PHP with AJAX. in the console you can easily track what … the POST/GET request made to PHP file and what is the responses shared by PHP file. try debugging response accordingly or… Re: Designers, Where Do You Get Your Visuals? Digital Media UI / UX Design by jkon … cases when we want more control over an AI-generated image or video. Of course, in those apps / sites, there's… past, I know they experimented with several AI services and image banks. What amazes me is that some of their AI… Re: Designers, Where Do You Get Your Visuals? Digital Media UI / UX Design by Dani I woke up today to find that my husband asked ChatGPT to generate an image of my dog. The coloring is correct with the exception of Sadie doesn't have white at the tip of her tail. Can I Use AI to Build a Block Management Website for Ilford Clients? Programming Web Development by kearawill Hey developers 👋 I’m working on a new project for a client — a estate agency Ilford, and I’m wondering how much of this could be streamlined or even built with AI tools? The site needs standard features like: Property listings Service request forms (for tenants) Payment gateway Backend for property managers to update info …