Skip to content

Tag: php

How to sort files by date in PHP

I currently have a script which allows me to output the list of files inside the same directory. The output shows the names, and then I used filemtime() function to show the date when the file was modified. How will I sort the output to show the latest modified file? This is what I have for now: Answer You ne…

How can I encrypt a cookie value?

How can I encrypt, and later decrypt, a cookie value in PHP? How secure will the encryption be? Answer I can not simply think of a situation where encrypting data in the cookie is useful. If you want to retain secret data about the user or his preferences, information, whatever, then store it on the server in…

Invalid argument supplied for foreach()

It often happens to me to handle data that can be either an array or a null variable and to feed some foreach with these data. When you feed a foreach with data that are not an array, you get a warning: Warning: Invalid argument supplied for foreach() in […] Assuming it’s not possible to refactor …

What is the “->” PHP operator called? [closed]

Closed. This question is opinion-based. It is not currently accepting answers. Closed 4 years ago. Locked. This question and its answers are locked because the question is off-topic but has historical significance. It is not currently accepting new answers or interactions. What do you call this arrow looking …