Skip to main content

Questions tagged [php5]

The fifth version of the PHP: Hypertext Preprocessor (PHP) scripting language. It features the Zend Engine 2, better object model support, and many other improvements over PHP 4.

Filter by
Sorted by
Tagged with
4 votes
2 answers
229 views

I am a newbie and have been following a tutorial I bought on Udemy. But I was told it is old and teaches bad code practices. I used this in some code from my old projects. Now I'd like to know how ...
user13477176's user avatar
-3 votes
3 answers
406 views

I was following a tutorial for a social network. I want to know how secure this code is because I plan on launching it to the public web. ...
user13477176's user avatar
0 votes
1 answer
271 views

The goal is to upload the columns from the csv into the SQL Pro database. I am able to select the column names that have been uploaded from the csv file, the columns from the csv file are then ...
Victor Melvin's user avatar
1 vote
2 answers
780 views

$elements is an array, which may contain 'x' or 'y' keys, I want to check if they exist, otherwise assign a 0. I'm looking for a clean way to validate it. I'm new ...
gogasca's user avatar
  • 609
3 votes
0 answers
58 views

I need to validate the fields of user sent by an API. All works fine but the only one problem is that I don't like the solution is not an OOP solution. In the controller I call the service created by ...
klsdskldsd's user avatar
1 vote
1 answer
111 views

I've found myself today really struggling with this subject and I'm pretty sure that there must be a better way to do this. First of all my arrays have the same layout, I need to merge them and sum ...
ccb123g's user avatar
  • 11
3 votes
2 answers
2k views

After a little bit of troubleshoots, I've finished this simple users registration and login class. It uses PDO to connect to a mysql database, I've tried also to ...
user9741470's user avatar
1 vote
1 answer
137 views

I am working with PHP5 (Laravel 5.1), and I couldn't optimize my function, which takes more 4 minutes turning, and fails in the end when I have a huge data (around 6500 rows, but working when i test ...
Gothiquo's user avatar
  • 127
0 votes
1 answer
49 views

I have made this code to determine the users grade for a quiz. However I've just been thinking that maybe I could shorten the code somehow? as its just a lot of if and elif statements. ...
user avatar
1 vote
1 answer
91 views

At my office we have an internal monitoring tool we use on customer systems to monitor various vitals and notify us via Slack. Our Lead Dev and Chief Architect are very paranoid about Git, and ...
Mayube's user avatar
  • 181
0 votes
1 answer
70 views

My method counts the number of times an error occurs. I have a feeling my snippet isn't the best practice way of doing this. So when one of the validation methods fails I want to stop the method. <...
Miguel Stevens's user avatar
1 vote
2 answers
2k views

I have a web application which is being used by users from different parts of the world. In order for users of the site, to be able to view the timestamps in their local time, I've a settings page set ...
asprin's user avatar
  • 187
2 votes
1 answer
147 views

I'm developing a MVC structured RESTful API project (thanks to the help of Mārtiņš Tereško for explaining it). Almost all of my functions look similar to this: ...
DaAmidza's user avatar
  • 289
1 vote
1 answer
194 views

I am using Joomla and connecting to an MSSQL database to store the resulting set(s) in arrays. I am utilizing this syntax, but there must be a more efficient way of coding this. ...
BellHopByDayAmetuerCoderByNigh's user avatar
4 votes
4 answers
9k views

I'm trying to work out which is cleaner, having a large constructor or having to use many setters on a new object before doing some work with it. Large constructor: ...
CJ Dennis's user avatar
  • 249
4 votes
1 answer
2k views

My needs are to manage DTO in a php5.3 application. I've written few lines of code in TDD with phpunit 6. The scenario I want to implement is a request with following fields: name surname password ...
sensorario's user avatar
1 vote
1 answer
135 views

Well Iam trying to learn OOP for a while now, My idea here is to create a simple CMS kind of thing.And I did something like this: App Class: ...
Rux's user avatar
  • 13
3 votes
2 answers
443 views

Following Database Class is what I'm using as a wrapper to connect with MySqli in a application, and below the class is how i'm implementing it currently I'm not sure if this is the right way to ...
Mohit Srivastava's user avatar
2 votes
1 answer
160 views

The objective of this piece of code is to get a message from a cryptocurrency daemon through RPC and extract the transactions object to pass it to the view. Is there a simpler / less ugly way of doing ...
Papa Lazzarou's user avatar
1 vote
1 answer
4k views

Well, I am writing a web service using PHP to return data from a DB in JSON format. I need to query 3 tables, which have a one-to-many relationship, like shown below: ...
user avatar
2 votes
1 answer
984 views

I'm trying to generate a report from two doctrine entities. The fields to filter the report are optional. This is the code I've got now and it looks really bad to me. How can I improve this? ...
Bob's user avatar
  • 21
1 vote
1 answer
10k views

Given a string, I've done the below to search a CSV for a keyword and display the row if it's found ...
pee2pee's user avatar
  • 380
1 vote
2 answers
2k views

I have this code but it takes over a minute to run. I'm looking at around 400 entries being brought back for the first loop. Any ideas on how it could be improved for speed? ...
pee2pee's user avatar
  • 380
2 votes
1 answer
225 views

I have this small program in PHP implementing merge sort. I used one rather simple run time optimisation via using one additional array which allows faster merge operations: ...
coderodde's user avatar
  • 32.3k
2 votes
1 answer
800 views

I've been working on a class(2 actually) that wraps around the array data structure of PHP. It doesn't bring anything new to the table, it simple makes the function ...
user2994883's user avatar
2 votes
1 answer
348 views

This was mostly made for fun, so I don't see it having any real world purpose any time soon. ...
Andrew's user avatar
  • 133
2 votes
1 answer
2k views

I'm implementing the Hotel Price List API from Skyscanner. This requires a first call to the service to implement a session followed by 1 or more calls to the service to get the actual results. I've ...
DiscoFever's user avatar
2 votes
2 answers
390 views

I need to optimize the below code, as much as possible in: using less resources as possible being as fast as possible What the code does is simple, it splits the string by words and only if a word is ...
Prix's user avatar
  • 165
1 vote
1 answer
149 views

I'm executing a cursor. I have cut off the code how the procedure is called and executed. This part is efficient. At last I have a small cursor. I'm calling the procedure, which returns this cursor ...
MaMu's user avatar
  • 235
1 vote
2 answers
2k views

I am new to PHP development. So Kindly, review my code and guide me make it better/optimize. Currently, it works well with inputs that I have tried. ...
Unbreakable's user avatar
1 vote
2 answers
3k views

PHP program which extracts attribute list from the custom tag. It also strips out the single and double quote if it exists around attribute value. ...
forethought's user avatar
1 vote
2 answers
781 views

Following yesterday's advice on my Customer class, I have now created a new class which is for looking up descriptions from a MySQL database. I have a Lookup table which contains type, name, value, ...
AndyH's user avatar
  • 43
3 votes
1 answer
4k views

I have been writing PHP for a number of years but in a procedural style. I have always shied away from object oriented PHP because I just didn't understand it. However now I'm back for another go. I ...
AndyH's user avatar
  • 43
5 votes
1 answer
130 views

Building complex applications can sometimes be a pain when extending or editing later on; I read online about the S.O.L.I.D principles of OOD, I want to understand if I am following a good approach ...
Mohsen Elgendy's user avatar
3 votes
1 answer
191 views

Can anyone here please review my PHP code which preserves line break by splitting the line into as many line break as it have? ...
forethought's user avatar
0 votes
2 answers
434 views

At my new job, with new young developers, we are seriously discussing improving code structure and performance. (They keep more than 80 lines of code in a method). However I've read more tutorials, ...
Heng Sopheak's user avatar
6 votes
1 answer
300 views

I've built a Search Engine class for a website that permits to search companies in base of their locations and their categories (companies pay a plan to be found in the places that they will). In the ...
Claudio King's user avatar
0 votes
1 answer
116 views

I've to authorize some users to do POST requests from their CMSs in order to create a new resource on my database. I've to send a JSON response containing the status of the response (successful or not)...
Claudio King's user avatar
2 votes
1 answer
443 views

I've been developing a forum as my first OOP project, I've successfully built a login/registration and other functionality typical in forums. I'm looking for some guidance in terms of where to take ...
Dannyw24's user avatar
1 vote
1 answer
118 views

I am doing a php project with the codeigniter framework. In my controller, I have a function that does the following. Uploads an image to the server Add a row to the database. The data would be ...
lightning_missile's user avatar
2 votes
1 answer
1k views

The following code works, I just want to know if there are any suggestions as to how I can make it better or more secure. config.php: ...
Alexiz Hernandez's user avatar
1 vote
1 answer
79 views

Here is my script which takes 50k records from a CSV and does CRUD operation with them. Unfortunately there are a lot of issues with the performance. CSV fields are: msisdn, resellerid, product ...
Sam's user avatar
  • 111
2 votes
1 answer
3k views

This is my first time using password_hash and password_verify in PHP. Would this be the correct usage of ...
Joe Scotto's user avatar
0 votes
1 answer
144 views

My question has to do with : (a) Can this be made more secure? (b) Are there best practices in relation to setting timezone? (c) What best approach should be taken defining use of utf8? ...
John Edward Law's user avatar
3 votes
2 answers
311 views

I'm trying to find the shortest and best way to achieve the following: Given input integer $N, get the following output: n = 0, output = 0 n = 1, output = 0 n = 2, output = 10 n = 3, output = 100 ...
Chilion's user avatar
  • 209
3 votes
3 answers
148 views

I have written a program to read HTML file, find particular text, write text from that particular text to next particular text in a newly opened file. I am interested in code review. I am very new PHP....
user101032's user avatar
1 vote
1 answer
94 views

I'm writing this method that elaborates an image name.. I think my logic is not being the best one here but I'm not very savvy in programming yet. Right now it looks like this: ...
Onilol's user avatar
  • 121
2 votes
3 answers
6k views

Given the following input values from a form, create a method or methods to validate the input based on their requirements. Throw an exception if any data is invalid. 1.1 ...
Unbreakable's user avatar
5 votes
1 answer
1k views

I have been learning object oriented programming for quite a while. I understand many concepts about it but I quickly realized that I made a big mistake just reading theory and not doing any actual ...
Erasus's user avatar
  • 240
3 votes
1 answer
120 views

I have an extremely large function for turning my database output of menu links into a multidimensional array that nests each of the links in a menu fashion. I'm wondering if anyone sees a way this ...
Eric Shoberg's user avatar

1
2 3 4 5