PHP is a widely-used, general-purpose scripting language that is especially suited for web development.

learn more… | top users | synonyms

1
vote
2answers
16 views

Method to get user information (OOP / MVC approach)

I coded a small user script with PHP. I'm improving the script, learning from my mistakes. I recently learned about object oriented programming and wrote 2 big god classes (user class and message ...
0
votes
1answer
26 views
2
votes
0answers
20 views

A PHP web crawler

I'm working on a "nice" crawler that start with one url, and find the other urls to process each page, a kind of "Google" crawler, to index pages. I worked hard on this crawler to respect many points ...
2
votes
1answer
22 views

Simple PHP MVC framework

I recently wrote this PHP MVC framework. Would like your review. index.php ...
2
votes
1answer
17 views

Database query with Eloquent

I have got two tables articles and tags in the database. My goal was to retrieve all fields from articles table and one category field from tags table with Eloquent. I couldn't do this so instead I ...
-3
votes
0answers
17 views

i need to change my form process into OOP [on hold]

this is my currently process.php how can i change this into OOP? im still trying to learn OOP and i could not figure it out.i also need to sanitize the $_POST and get it into OOP class somehow. if ...
0
votes
2answers
48 views

PHP MySQL connection class

I'm trying to build a class that connects to the database. It does the job but it is not very elegant. I also have no understanding of singleton class or dependency injection. Is this safe? Can you ...
1
vote
3answers
39 views

Building session array from post to build search query

So I am making post requests to a page for search queries. I am turning them into a session array so I can paginate the results. The process kind of feels ugly and long winded. I need code review for ...
2
votes
0answers
28 views

Managing PostgreSQL transactions for concurrency

I have a situation where I need to use PostgreSQL's serializable isolation level for transactions. This is for a table shared among multiple concurrent PHP processes. If the database runs into any ...
-2
votes
0answers
23 views

Can I please get some feedback on my coding technique for object oriented php? [on hold]

I'm looking at getting a job as a php developer. I have submitted tests, but not heard back from them. Can I please get some feedback on my coding technique for object oriented php? Here is a test I ...
3
votes
1answer
48 views

PHP Login/cookie authentication

I have an authetication api for an intranet site but I'm a little worried that my design of the authentication is bad and unsafe. Below is the basic part of the authetication process and I hope I can ...
-1
votes
3answers
84 views

Is it good to have a method accepting an array of keys to return it's values? Does it break OOP concepts?

Here is my ValueObject example class. I wrote this example for my OOP research. I know I could use ArrayAccess interface but I am curious abobut feedbacks about this class. Does it break OOP concepts? ...
-3
votes
0answers
26 views

PHP mysql incorrect code? [on hold]

I have this script ...
1
vote
0answers
41 views
+50

Basic CRUD in Laravel 5.2.37

Controller class ...
3
votes
2answers
53 views

Checking the status of a website by hitting a PHP script

I currently have a system which loops through a bunch of my website domains and checks their status and sends me a notification letting me know if they are up or down. The stripped down version of the ...
3
votes
1answer
77 views

More efficient method to check for duplicate database entries?

I am saving company information in a database, and if repeat information is found, I want to update the overlapping rows. Some of the supported fields are emails, phone numbers, organization names, ...
1
vote
1answer
23 views

Create JSON file from WordPress ACF options

I am using a WordPress multisite network and want to pull information from options pages in Advanced Custom Fields to create a json file. I currently have this code running whenever an options field ...
1
vote
0answers
32 views

PHP how to build html in class

I am used to procedural PHP. However, I have a piece of code that needs to be repeated a lot. I was thinking of trying my hand at creating a class. All is going well and it is working, but I think ...
0
votes
2answers
47 views

PHP program which extracts attribute lists from custom tag

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. ...
0
votes
2answers
58 views

Logging in with multiple types of info

I'm trying to let users log in with multiple columns (e.g. ID, email, phone). If one fails, it checks the next column. I would like to minimise my if and ...
2
votes
2answers
50 views

Level system in a gamification platform

Currently, I'm working on gamification platform and I have the following rules for achieving a new level: Level 0: When user registers Level 1: When user confirms account Level 2: When user ...
-1
votes
0answers
22 views

Why is it bad, if an entity can save itself? [closed]

with a few ORM I can see that: $entity = new TableName(); $entity->setName('username'); $entity->setPassword('zxbvc'); ...
2
votes
1answer
42 views

Queries for the number of users seen each day

The below code returns an array filled with the number of users last seen for each day for $dayCount number of days that is specified via a parameter into the ...
4
votes
2answers
84 views

Social network queries for profiles, posts, and followers

The code below is for a social networking system. The problem is that when there are many posts and many followers, the performance is slow. Is something wrong with the queries and the script below? ...
1
vote
1answer
26 views

PHP Script to write values from JSON on image and display image

This is a script I made that opens img.png, downloads the json data from the API, writes it on image and displays it. It currently is a community ad over Arqade. ...
2
votes
2answers
40 views

Ensuring valid origin and destination countries

Having the following code in PHP 5.2, where: $row: Is an array that contains some things, but the ones that are interesting for the post are ...
0
votes
4answers
147 views

How can i rewrite this code block with array_map or array_walk?

Actually, I don't like to write for/foreach. I had to write a loop. I would like to replace it with ...
1
vote
1answer
29 views

Cloning Distinct XML structures without data in PHP

I struggled for the last couple days on this question and finally came up with a solution. But it's got so many loops I get dizzy just looking at the code - from recursive functions with loops to ...
0
votes
1answer
71 views

Password Protect Page with PHP

I am using the following code to password protect pages on my site. This is how I am including it on a page: ...
1
vote
1answer
139 views

Using cURL to retrieve remote image

I am using the following code to retrieve the URL of a random image in a remote folder that I own. As a newbie and although this is working I would like to know if this is done properly, if it could ...
0
votes
0answers
28 views

Laravel dropdown list without empty values

I'm creating dropdown list from all possible cities in database, all cities are distincted. ...
-1
votes
0answers
31 views

How to add some items to an array based on a condition?

I have these two queries: ...
-3
votes
1answer
29 views

Correct indentation for writing php array with a long html value in it? [closed]

How would I properly indent this code in PHP (I'm using WordPress)? I'm mostly concerned about how the <button> comes into this equation @ ...
1
vote
1answer
43 views

Regex Tool in PHP

I'm looking for feedback about anything and everything to do with this short program. For example, is there a risk in not sanitising the data, and if so, how would I do that given the need for non-...
0
votes
2answers
56 views

Division number and remainder php code

I created a function that will tell me how many times a number is divisible by another number and what the remainder of it is: ...
3
votes
1answer
72 views

Storing MySQL data in Memcache

I have written a script that checks if data is known in memcached, and if not it queries it from the mysql db and stores it. I would appreciate any inputs if i have done this the "correct" way, since ...
0
votes
2answers
30 views

Lookup class to get descriptions of values

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, ...
3
votes
1answer
150 views

Simple SQL query using a class and function

welcome to my first post :D 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 ...
3
votes
1answer
32 views

Access an associative array value given an array of keys in PHP

I have an object which stores an app configuration in an associative array, as this: ...
0
votes
2answers
13 views

Access an associative array value given an array of keys in PHP

I have an object which stores an app configuration in an associative array, as this: ...
1
vote
1answer
45 views

Galaxy generator

I'm currently working on a galaxy generator, and I was in need of getting the next that a random would use, for continuing the generation without using a blank generation (re-run previous generation). ...
0
votes
0answers
57 views

Check if a user is authorised to visit a page

I'm creating a user portal for our customers but I'm yet to find the best way to check if a user is logged in or not. I used to check it by setting some session variables with my ...
1
vote
3answers
39 views

Handling large amount s of ajax/POST commands

I'm currently creating a utility that is heavily AJAX orientated. I have a page called ajax.php which is handling all POST requests. It switches by the provided command, checks all the arguments exist ...
1
vote
1answer
73 views

PHP Class code that allow developers to register taxonomies in a CMS

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 ...
1
vote
5answers
61 views

A like/unlike system using MySQL and PDO

I have created a Like/Unlike system. The user clicks one to indicate a "like", and clicks again to "unlike" it. Currently I do that like this: ...