Tagged Questions
23
votes
7answers
2k views
is_numeric_array() is missing!
I found that in PHP (or I probably can't find it) a proper is_numeric_array($array) function is missing. So I created one. The problem is that I don't think it's ...
8
votes
3answers
330 views
Can I use this function to store passwords?
Just wrote this function, wondering if it's secure enough to store passwords in a database:
...
8
votes
1answer
175 views
PDO sign up function inserting data into multiple tables
This is a sign up function called on form submission. It firstly inserts key user data into the users table. If successful, secondary data is then inputted into ...
6
votes
2answers
178 views
Pattern to avoid Variable Functions?
I have some PHP code where I use Variable functions to call the right function. I need to build a chart array (for example), and the chart array that comes out has a fixed format. But the data that ...
3
votes
2answers
141 views
Updating necessary data using just one function
My objective is to update necessary data using one function instead of having different functions to update different fields. So, I've created one and I think this is not really elegant, efficient or ...
3
votes
2answers
72 views
Merging the results of two functions
I have a class which extends another class and override one of its parent methods.
...
3
votes
1answer
317 views
How to improve function to detect the mime type using an agnostic method?
This function is used to get the mime type of any given file. The intended purpose was to have it working within any of our servers that vary from the latest PHP version down to PHP 4.
...
3
votes
1answer
60 views
How does this function look?
What do you think of my function. It is used to change a cyrillic word with a stress marker into the same cyrillic word but with the stress marker seperately represented as a number. As I want to ...
3
votes
1answer
844 views
Passing anonymous functions and getting variables from an outer scope in php
I'm doing something quite strange. I'm trying to create a tiny system for creating templates inline in php, so that I can refactor by creating multiple templates in the original script, and ...
3
votes
1answer
263 views
WordPress Functions.php file
I am making a WordPress "framework" for myself. Looking at the functions.php file file, is there redundant or bad code that could be changed or some code that could be good to add?
The functions.php ...
2
votes
2answers
218 views
How to optimize a function to get user quota stats?
I have the following function to collect quota information for the given user and return the information on a "ready to use" array:
...
2
votes
3answers
112 views
Checkbox Group Function and Usage
In CodeIgniter, I have created function (helper) to populate, store and retrieve checkbox group. I just wonder if I have written code is in proper way and optimized or needs some more finishing?
...
2
votes
1answer
82 views
Single function to read one, read all, or set
I have the below function, it is designed so I can call:
...
2
votes
2answers
484 views
Best practice for converting minutes and seconds in seconds
I have 2 input fields to input the duration of a CD song. The first input is for minutes and the second is for seconds
When submitting the form, I must insert in the db the duration either in seconds ...
2
votes
1answer
86 views
Calling multiple functions in image upload form
I have an image upload form with which I call multiple functions before uploading the file such as checking the size and dimensions, and that it is in a valid image. The code works, but calling the ...
2
votes
1answer
132 views
How can this function to get a remote file improve?
I've prepared a function using cURL to get a remote file to the local storage:
...
2
votes
2answers
481 views
PHP and Custom Functions
I am new to the world of coding as well as XHTML and PHP. As a way to gain more experience as well as to put theory into practice including a way to challenge myself, I put together the following code ...
2
votes
0answers
435 views
PHP - faster/better implementation of is_dir function for FTP/FTPS connections?
I'm implementing an is_dir() function to determine if a given item is a directory or a file for FTP/FTPS connections. Currently, I have two methods: one using PHP's ...
1
vote
2answers
104 views
Is calling a function from within another to alleviate code duplication the best solution?
I am writing up a class to handle various templates to be used in a web application. Each template contains various placeholders which will need to be replaced at the time of the build. I a wondering ...
1
vote
2answers
106 views
How to improve this PHP function to confirm the presence/create directories?
While preparing an automated process to manipulate files, I've made the following function to check for the base directory and sub-directories presence, as to allow or deny the remaining code to be ...
1
vote
1answer
47 views
Optimising and consolidating multiple PHPMailer functions
So the two functions below both send emails via PHPMailer but both hold different messages (which use different data from the db). I was just wondering (as I plan to use PHPMailer more) a way to ...
1
vote
1answer
65 views
Test 2 time ranges to see if they overlap
I am doing a project for school and had to create a function to check if 2 time ranges overlap. I searched the net a bit but failed to find a simple function to do that. I played around a bit with my ...
1
vote
1answer
147 views
Feedback on a small PHP function that generates JSON data
I wrote a PHP function that generates JSON data to populate a line graph. Through jQuery, my code uses a GET request to the PHP script to fetch the JSON data. An example of the JSON data is as ...
1
vote
1answer
264 views
If statements in validating different form data types
I am using if statements within my functions to validate form fields and then on the isset event.
I want to be able to create many different functions to validate various fields groups and it seems ...
0
votes
2answers
217 views
A better way of writing a PHP function
As the title says, I'm looking for a better way of writing the following PHP function as it's a very very long one. It's part of a bigger class and I'm trying to keep the amount of code as little as ...
0
votes
2answers
289 views
PHP PDO Custom class ple
i created a database class from a good tutorial and wanted to put it up here so it would get in some search results. it took me about 2 days to find it. also i added a few custom functions to it.. ...
0
votes
1answer
112 views
Refactoring functions that generate string with random letters, numbers or mixed chars?
The bellow functions are used to generate a string with random characters, and they have a parameter to specify the string length.
The string can be composed of letters, numbers or a conjunction of ...
0
votes
1answer
263 views
Is my login function secure ? how to improve it?
Using cakePHP, I would love to have your point of view about this large source code, i am not sure if its enought secure. sha1() will be removed with another ...
0
votes
1answer
29 views
Add user star function triggering PHPmailer email optimisation
The function below simple allows a logged in user to "star" another user for convenience when trying to find the that user another time. At the moment the function works as it should, it inserts the ...