Skip to content

Tag: php

PHPExcel: Download the Excel file on the client side

The problem was solved: For other users that may have this problem – notice the encoding of the PHP file. If you use PHPExcel it must be ANSII encoding and not UTF8, otherwise the EXCEL will be downloaded corruptly. The Headers that were added (answer 1) solved the problem after i changed the encoding o…

Creating a very simple 1 username/password login in php

I want to make a single login for just 1 user without storing in a database but I can’t seem to get this to work. My code: login.php trylog.php Answer Your code could look more like: Now, when the page is redirected based on the header(‘LOCATION:wherever.php), put session_start() at the top of the…

PHP find the days until a date

I have to find the number of days until a date in timestamp format (mysql db) My problem is that if date now is 2013-12-01 09:59:00 the days are 15 while datenow is 2013-12-01 10:01:00 the days are 14. How could I make a difference only of the days without the time? Answer Using the DateTime class: returns

Image in text line is slightly offset

I’m trying to make a clickable button by treating a hyperlink with CSS and adding a little icon next to it. Everything but one detail works great; namely the icons which are slightly offset from the text on the button. It looks as follows: As you may see, the white icons (12x12px) on the buttons are sli…

when it is required that a class will be defined before instantiation?

In the PHP documentation it says: Classes should be defined before instantiation (and in some cases this is a requirement). can some one give me a example of a class that can not be instantiated unless it was previously defined? Answer The parsing rules are the same as for functions: if they’re defined …

PHP Methods and Class Design [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 last year. Improve this question Which design concept is better in PHP; passing variable to the function…