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
3
votes
1answer
11k views

Database report in PHP

Just a small PHP exercise to write some simple reports, I thought I'd do it without a framework for fun and profit. I'm particularly concerned about the potential for SQL injection, since the user ...
0
votes
2answers
115 views

how to simplify this code [closed]

I'm just wondering if you see any ways I could simplify the following code without making it too difficult for a newbie to understand what I'm trying to do: ...
2
votes
1answer
14k views

How to properly use OOP in PHP with forms

I am trying to wrap my head around how to properly use OOP in PHP when dealing with form submissions. The example below is a form for editing course information. I have a class called Course which ...
1
vote
1answer
95 views
1
vote
1answer
133 views

jquery.php plugin security optimization (backend)

This is the backend to my jquery.php plugin which handles requests to make function calls and execute PHP code that is sent in various forms. After requests are processed they're sent back to the ...
1
vote
2answers
155 views

Foreach removal of Magic Quotes PHP

I'm looking to remove all magic quotes at the start of my PHP script (if they are turned on). The code I'm using to do this is rather simple, so I was wondering if I was overlooking anything: ...
2
votes
1answer
263 views

Passing a large amount of diverse information in JSON using Symfony 2.1 and Doctrine 2

For a project I need to give a load of diverseinformation in JSON format. All the information will be used on the same page so a single call would result in the least overhead. The information all ...
0
votes
1answer
1k views

SocialEngine 4: Edit Post / Comment feature [Anything that can be improved? ]

So, I have coded a PHP script that will make it able for the users to edit their Post, or comments on a site that runs SociaEngine 4. So, Is there anything that could get inproved/fixed on this? <...
2
votes
1answer
2k views

Review my Diffie Hellman class

Here is a link to my project, more details regarding the Diffie Hellman Key Exchange using MODP cyclic grous are available here, no ECP currently implemented https://en.wikipedia.org/wiki/...
1
vote
2answers
164 views

Image upload script

Listening to mseancole's advice in my previous post, I have rewritten the code. ...
1
vote
1answer
255 views

Accessing a REST API with PHP

I'm currently using a scientific information management system that employs a RESTful API. I've never used this API with PHP, and I had a hard time finding best practice examples online. After some ...
2
votes
1answer
2k views

The perfect PHP login script

I posted this same question on StackOverflow but guys over there told me to post it here. I have programming in PHP since past 2 years and yet haven't found a perfect script for logging the user in. ...
0
votes
1answer
309 views

Review: Finished router class for custom mini framework

I have finished my router and would like your thoughts on anything that may be inefficient of could be done better!: class Router { ...
2
votes
1answer
2k views

Is there a better way to loop through records and call an api?

I have a CakePHP function here that gets info for a twitter screen_name from the twitter api and writes it to a mysql db. I'm just looking for feedback about other ways to accomplish this that might ...
2
votes
3answers
803 views

Would a plugin for calling PHP functions within JavaScript prove useful?

So basically jqueryphp is a jQuery plugin that allows you to call any PHP function within client-side JavaScript: jqueryphp@github I wrote it as a response to projects such as PHP.JS and other ...
2
votes
1answer
1k views

PHP Mvc code review

I'm fairly new to mvc and almost finished my auth class I wanted to check that I'm using it all correctly any feedback would be welcome. I used the PIP framework to get started http://gilbitron.github....
3
votes
2answers
350 views

Better way to return data via AJAX?

Let's say I have three files: a page that is used for searching data called search, a file that handles requests called controller, and a file that has functions which the controller calls based on ...
3
votes
2answers
2k views

Small MVC for PHP

The following is a new question based on answers from here: Small PHP MVC Template I have written a small MVC template library that I would like some critiques on. The library is located here If ...
3
votes
1answer
104 views

Drupal: Placing Code (PHP) within the Drupal System (as well as css)

I have a node template that grabs fields from a content type. In the node--[contenttype].tpl.php file I have two sections (The second is html/php and grabs variables from the first section or from ...
2
votes
2answers
4k views

Best Practice: Learning PHP OOP

I am learning PHP OOP. I am familiar with PHP, and limited use of OOP, but not writing OOP. I have a small successful website that uses large associative arrays but is now suffering performance ...
3
votes
1answer
766 views

Unicode parsing in PHP

Firstly, apologies if this is not the correct type of question for here, I had it on the stackoverflow but it was closed with a suggestion I post here. I’m in the process of converting from Latin 15 ...
9
votes
4answers
10k views

Is this a proper way of “loading” views in PHP?

As a learning exercise, I'm developing my own PHP framework. I'm looking for a way to "load views" (kinda like CodeIgniter does it), without polluting my general scope. I came up with the following, ...
0
votes
2answers
460 views

Generalized Sql Query Function

One thing I realized while going through code yesterday at my internship is that I run sql queries quite often. So I decided to write a function to keep all of the calls in one place and reduce the ...
1
vote
2answers
518 views

PHP api design - anything done badly?

I have created an api in php and I was hoping some clever individuals would mind reviewing it to see what I could do better. I have commented it heavily to explain my reasoning. please feel free to ...
5
votes
3answers
5k views

PHP Form generator class

I have made the following classes and objects. It was made to create forms programattically easily. It should produce highly readable, valid, and clean HTML. Care to give me some feedback? :) https:/...
1
vote
1answer
146 views

Preg_replace improvement

I would like to improve my preg_replace regex. This is to clean a features list. I want allow for the begining of each line: alphanumeric characters == and alphanumeric characters -- alphanumeric ...
2
votes
1answer
262 views

The right way to get formatted node's body field in Drupal 7

I am wondering am I doing the right "Drupal" way in getting formatted value of node's body field. Here is my code: ...
3
votes
1answer
187 views

Variable cleaning class

I've created a class that's used for cleaning variables for use. You set a name, value and options and it will set the value if it matches the criteria/options. It is used like this: ...
1
vote
2answers
152 views

Delete matching ID and insert new data

Delete all matching ID Insert new data function add_date($id,$date) { ...
1
vote
1answer
357 views

OO PHP, requesting a look if good practice

I'm starting with OOP for php, i get the idea, but don't have someone physical near me to fallback on so I'm hoping i can do that here. The following works but i would like to know if it's good ...
2
votes
1answer
337 views

Optimize PHP Class

I'm looking for a better way to provide configuration options and improvements in general. I'm using the constructor injection pattern to get access to the Cache and Twitter class. ...
2
votes
1answer
243 views

Counting Facebook and Twitter Reactions

I wrote / modified two scripts to count Facebook and Twitter reactions. Anything I can do to improve these? Count Facebook Reactions ...
2
votes
1answer
118 views

Can my router code be improved?

I have created a nice url structure for my site. In my .htaccess I have: FallBackResource /index.php And in my router class I have: ...
1
vote
2answers
1k views

Have to hardcode Array values when using PHP arrays in JS

In the code below , i'm only able to get PHP arrays in javascript to work when I hard code the value . Is this the only way to get it to work, or is their a way to copy the entire PHP array into ...
1
vote
2answers
68 views

How should I format my code to make it easier to read and understand in the future

I am using this query to generate a conversation stream between user 184 and 192- ...
1
vote
2answers
2k views

Checking form input data on submit with pure PHP

I have some experience with PHP but I have never even try to do this wit pure PHP, but now a friend of mine asked me to help him with this task so I sat down and write some code. What I'm asking is ...
3
votes
2answers
4k views

PHP Login/User Creation Validation Function

I'm VERY new to PHP and have begun writing a basic login for a website that uses data from a Microsoft SQL server to display information on the web. Below are 3 snippets of code (two functions from ...
2
votes
2answers
136 views

array_mask, Seeking alternative code

I would really love to hear your critiques on: Code quality Code clarity More efficient alternative code Code: ...
4
votes
2answers
3k views

PHP SQLQuery class

I created a PHP class to handle building SQL query strings. I need advice on how to make the code more efficient. ...
3
votes
2answers
1k views

php highlight search keywords [working solution]!

I just spent the whole night writing this little script for my search engine. Now i want to improve it. Any ideas? ...
3
votes
1answer
3k views

Simple PHP Router

Based off simple controller implementations like those seen in micro-frameworks like Slim, Silex, F3, Laravel, Tonic, Flight, Klein, etc. /EDIT tried to link the above sources, but as a new user I ...
2
votes
2answers
271 views

Separating logic and presentation in wordpress

Recently, I've been thinking about better ways to make my WP themes more maintainable. What I've tried on one of my last projects is to separate out the presentation and logic as much as I can. First, ...
2
votes
1answer
147 views

Need unique url but require non unique information from other columns

I am making a review system and I need to be able to only select the DISTINCT url from the database, but then pull the relevant page title and rating time. I have managed to get it working by using: <...
4
votes
3answers
2k views

OOP PHP form ok?

I am new at OOP and I wonder if the code below is OOP or it can be better and also what can be better? ...
2
votes
1answer
523 views

Improving a “Http request URl builder” to be shorter, faster, easier to read

I've setup up a nice, little parent class that I can extend easily to do Http request to servers offering some sort of data with JSON/XML/whatever output. You can see the ...
1
vote
1answer
87 views

Getting personal messages function

I'm trying to develop a better function and curious what others would suggest I do to it so that its not so robust and still accomplish what I need. A couple of things I need to account for is when I ...
2
votes
1answer
180 views

Set of classes for generating social plugins, is my design correct?

I've created a set of classes thatwork together to create the html needed to display social plugins like Facebook like, google plus and twitter. At firsti defined an abstract class ...
2
votes
1answer
120 views

Better way to incorporate HTML and PHP

When I look at this style of code I feel like there has to be a better way to write this: ...
2
votes
2answers
567 views

Is this PHP email validation comprehensive and complete?

It might be a bit redundant, and I'm not experienced enough to wrap it all into one function. But, I'm aiming for unicode email adresses and a quick loose but secure validation. How can I improve this?...

1
77 78
79
80 81
85