Questions tagged [php]

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

Filter by
Sorted by
Tagged with
2
votes
1answer
879 views

Polling script to determine the continuous time a user has been connected

I've been asked to keep track of how long a user has been connected to a site without interruption. So far the solution I've come up with is to use ajax to poll the site every now and then to check ...
4
votes
1answer
893 views

Wrap email quotes with html element

I'm wondering if I could handle the following situation with a single function or regex call. Given the folowing input: ...
4
votes
1answer
3k views

Copy a file, renaming it if the destination already exists.

I would love some feedback on this little utility function: ...
3
votes
1answer
473 views

Improve OOP code

I am learning OOP and have written a class for Likes. There is a load, add, delete method and I think this code can be improved since there is a lot of duplication. Please let me know how I can ...
4
votes
2answers
2k views

How can I improve this PHP MySql Rank generation function?

How can I improve this PHP MySql Rank generation function? (Mostly looking to improve speed, but any feedback is very welcome) Right now I keep stats and ranks in 2 separate tables. The only ...
2
votes
2answers
2k views

Event Registration

I am new to the world of coding, PHP as well as XHTML. As my first stab at object oriented coding, I put together a basic registration form that is meant to serve as a means to collect user details. ...
6
votes
3answers
1k views

PHP Table generation

I have been using the following function (in the kohana html class in a table) to generate tables. ...
7
votes
1answer
4k views

Workaround for overloaded constructor in PHP

I have a class whose purpose is to display a comment. I'd like to be able to instantiate it by passing a Comment object if I happen to have it available, or just ...
3
votes
2answers
1k views

PHP Output Block Defining and Best Practices

I've been rolling around several ideas or approaches in my head, and none seem any more useful or "right" than another. I'm sure this is extremely objective but I'm looking for a close-to-definitive ...
1
vote
1answer
228 views

Have I gone too far in factoring out repeated code in this example?

In a controller (PHP, CodeIgniter) I'm adding scripts & css to variables to be used in the view output. My initial coding looked like this: ...
3
votes
2answers
4k views

PHP Questionnaire Code Peer Review

I just started learning how to code PHP as well as HTML and as a challenge for myself I put together a questionnaire with what I have learnt so far which isn't as much as I would like to know e.g. ...
4
votes
1answer
729 views

Implementing PDO, code correct so far?

I have decided to go PDO and have started implementing it on one of my webprojects. I have limited programing skills but can usually pull it off with some tutorials and forums. Here is my code this ...
4
votes
3answers
1k views

73 Lines of Mayhem - Parse, Sort and Save to CSV in PHP CLI

Inside of a folder named txt I have 138 text files (totaling 349MB) full of email addresses. I have no idea (yet) how many addresses there are. They are separated ...
6
votes
5answers
430 views
3
votes
3answers
325 views

PHP, Is creating a class for templates to much?

I am new to using classes heavily, and was wondering if going so far as to create a class specifically for templates was going to far. Here is a simplified version of my class template. Yes, I know I ...
6
votes
2answers
398 views

Cart Class feedback

I have written a cart Class, it use session to store data. Is the code well implemented or could been better? You can rewrite my code if you can. Each item have a number of options with price Each ...
5
votes
1answer
2k views

Review for a PHP socket proxy

For my current project we are commnunicating with an old mainframish hospital information system. This system has a service called 'Facelink' which is a simple TCP connection with a fixed set of ...
5
votes
2answers
524 views

Splitting code, am I doing it right?

I would like to have my code reviewed, I'm trying to get a general model I'm using for my stuff going and I don't want to keep using wrong or inefficient code if I can. My file structure is like this:...
7
votes
1answer
242 views

Do nothing lamda…

$privilegeStrings = array_filter($privileges, function ($s) { return is_string($s); } ); Is there a better way to specify that I want just the string values in ...
1
vote
2answers
146 views

Best way to use an array that is returned from a function immediately in PHP

I have a function that returns an array and I want to check that a certain value is not set in the array. ...
10
votes
2answers
717 views

Object Paradigm for PHP, Practice in Design

I've created and I manage a point of sale web application built in PHP which has thus far followed no clear guidelines or methodology for development; it's operation is completely procedural. In turn, ...
9
votes
2answers
1k views

Critique My Codeigniter Custom CMS Pages Model

I am currently developing a custom CMS being built on top of Codeigniter and was wondering if you can spot any flaws in my page fetching model code. The page fetching model is not entirely complete ...
10
votes
1answer
2k views

Php/Doctrine array hydration

According to the Doctrine docs, you should use Array hydration rather than record hydration when retrieving data for read-only purposes. Unfortunately, this means I have to use array syntax (as ...
9
votes
1answer
437 views

Database method to query

I have a database class that in __construct() initialize a PDO connection and insert the instance into a $db private var. Now i'm working on a method that can be ...

1
80 81 82 83
84