Skip to content

Tag: php

Creating a variable from a large, complicated section of html

I have several large (200+ lines) of html that I need to place in a variable to use several times in a loop. It gets very messy to escape this and that and keep formatting clean. Is there anyway to set a variable like this IF statement? I know its possible with external files, but Id rather not add a

Why would $_FILES be empty when uploading files to PHP?

I have WampServer 2 installed on my Windows 7 computer. I’m using Apache 2.2.11 and PHP 5.2.11. When I attempt to upload any file from a form, it seems to upload, but in PHP, the $_FILES array is empty. There is no file in the c:wamptmp folder. I have configured php.ini to allow file uploads and such. T…

Php Destructors

Please give me some real life examples when you had to use __destruct in your classes. Answer Ok, since my last answer apparently didn’t hit the mark, let me try this again. There are plenty of resources and examples on the internet for this topic. Doing a bit of searching and browsing other framework&#…

PHP: How do I detect if an input string is Arabic

Is there a way to detect the language of the data being entered via the input field? Answer hmm i may offer an improved version of DimaKrasun’s function: okay, enough joking! Pekkas suggestion to use the google translate api is a good one! but you are relying on an external service which is always more …

How to replace new lines by regular expressions

How can I set any quantity of new lines with a regular expression? I need to remove every new line (n), not <br/>, between two paragraphs. Answer To begin with, str_replace() (which you referenced in your original question) is used to find a literal string and replace it. preg_replace() is used to find …