I am trying to learn more about the PHP function sprintf() but php.net did not help me much as I am still confused, why would you want to use it? Take a look at my example below. Why use this: When this does the same and is easier to write IMO: Am I missing something here? Answer sprintf has all
Tag: php
How to create an error 404 page using PHP?
My file .htaccess handles all requests from /word_here to my internal endpoint /page.php?name=word_here. The PHP script then checks if the requested page is in its array of pages. If not, how can I simulate an error 404? I tried this, but it didn’t result in my 404 page configured via ErrorDocument in t…
How do I throttle my site’s API users?
The legitimate users of my site occasionally hammer the server with API requests that cause undesirable results. I want to institute a limit of no more than say one API call every 5 seconds or n calls per minute (haven’t figured out the exact limit yet). I could obviously log every API call in a DB and …
What is PHPSESSID?
I’m playing around with cookies. And I dont have any cookies called PHPSESSID. Do i need it? Can i remove it? Whats the “function” of it? Prints: Answer PHP uses one of two methods to keep track of sessions. If cookies are enabled, like in your case, it uses them. If cookies are disabled, it…
Is there a way to get all of a DOMElement’s attributes?
I’m reading some XML with PHP and currently using the DOMDocument class to do so. I need a way to grab the names and values of a tag’s (instance of DOMElement) attributes, without knowing beforehand what any of them are. The documentation doesn’t seem to offer anything like this. I know that…
How do I set the selected item in a drop down box
Is there any way to set the selected item in a drop down box using the following ‘type’ code?
how to call a function in PHP after 10 seconds of the page load (Not using HTML)
Is there any way to call a function 10 seconds after the page load in PHP. (Not using HTML.) Answer This code works. Edited from randell’s answer. Thanks to randell
Zend Framework how to set headers
I have a question, how can I do something like this: header(“Content-Disposition: inline; filename=result.pdf”); header(“Content-type: application/x-pdf”); With Zend Framework, …
DBM or SQLite in PHP 5.x
We have a client whose site is hosted on a server (I don’t want to disclose hosting company name) which does not provide DB functionality. We have developed a very simple CMS based site but out implementation uses MySQL. I read somewhere that there are DB like functionality built-in in PHP. I have never…
Which additional securities do you add to your open source cms installations? [closed]
Closed. This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post. Closed 1 year ago. Improve this question I know that being open source does not necessarily makes a program mor…