I’m trying to write a regular expression that checks if an email form field contains a free email address, with no luck. Essentially I need to check if the email contains: hotmail, yahoo, gmail etc in the email field. Answer regex would be sth like: you can add all the other domains you want… does…
Tag: php
Get fragment (value after hash ‘#’) from a URL in php [closed]
How can i select the fragment after the ‘#’ symbol in my URL using PHP? The result that i want is “photo45”. This is an example URL: http://example.com/site/gallery/1#photo45
Return an array from mysqli stmt query
I’m trying to convert a site to use prepared mysql statements, however I’m having some trouble replacing my use of fetch_array(). The comments on php.net offer a solution which I would have thought should work but for some reason I’m getting strange undefined constant errors when calling a f…
Create a folder if it doesn’t already exist
I’ve run into a few cases with WordPress installs with Bluehost where I’ve encountered errors with my WordPress theme because the uploads folder wp-content/uploads was not present. Apparently the Bluehost cPanel WordPress installer does not create this folder, though HostGator does. So I need to a…
Remove zero values from a PHP array
I have a normal array like this Array ( [0] => 0 [1] => 150 [2] => 0 [3] => 100 [4] => 0 [5] => 100 [6] => 0 [7] => 100 [8] => 50 [9]…
PHP – lookup array contents with dot syntax [closed]
Closed. This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed 7 years ago. Improve this question Does anybody see anything wrong with the following function? (Edit: no, I don’t think …
php setcookie domain
Some application, not written by me, and not in PHP, creates a cookie for the domain “www.domain.com”. I am trying to replace that cookie. So in php I did: setcookie(‘mycookie’,’mydata’,time() + 2*7*…
Lightweight PHP5 based template class/system
Looking at using a template system for a new project, it’s only a small site and don’t want to use the overhead and ‘complexity’ of smarty. I don’t really like template systems that force you to make use of another language just to make it easier for designers (apparently). Somet…
SHA1 vs md5 vs SHA256: which to use for a PHP login?
I’m making a php login, and I’m trying to decide whether to use SHA1 or Md5, or SHA256 which I read about in another stackoverflow article. Are any of them more secure than others? For SHA1/256, do I …
Decimal validation + PHP?
How to do decimal number validation in PHP? (The decimal point is optional) it should accept … 0 , 1 , 2 , 0.123 , 0.2 , 12.34 etc. Answer Would any of these suit your needs? is_float() is_numeric()