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

learn more… | top users | synonyms

2
votes
0answers
7 views

CodeIgniter: Best practice for generating JQuery dynamical content

I am new user of CodeIgniter and I am trying to build an application that there are lots of JQuery dynamical content. Below I provide a code that I am using in order to be precise. The code below is ...
-1
votes
0answers
16 views

setting the right path for php command line scripting in windows [on hold]

Good day I have been trying to set the right path for php in order to start new web applications in Yii. My PHP is installed in the C:\xampp\php directory, but setting this path in my settings does ...
0
votes
0answers
18 views

MVC in PHP: store and verify user input [on hold]

I'm trying to write an MVC script in PHP. I've an object, e.g. a car, that can be booked. I created a class "car" and a child class "carEdit". In carEdit the controller can easily store and verify ...
4
votes
1answer
32 views

A PHP Toolkit of some functions

Any major security risks? And please don't get angry over my novice log system. <?php function makesalt($lg) { $chars = ...
-2
votes
0answers
13 views

how can i add cache for pdo query? [on hold]

i have this query but i dont update this table more than one time in week how can i add cache to this query? <?php $jds="SELECT tc,tn,tb,tfz,tmz FROM teams WHERE leag='$lig' ORDER BY tmz DESC, ...
2
votes
0answers
23 views

Benchmarking PHP requests [on hold]

I am using Apache ab to test one simple file and Zend application. Zend application page is default page that comes with skeleton application. And another file is show below: $start = ...
1
vote
0answers
40 views

PHP session fixation

I'm trying to implement a system of restricted access. Right now I'm focusing on the "session fixation". I am concerned about the following aspects: Control of a "fingerprint" of the user created by ...
5
votes
1answer
61 views

GIF to HTML5 video conversion

I'm still at a very beginner level and I'm constantly working on small things to try and develop my skills. I'm hoping someone could just give me a quick review if there's anything obviously horrible ...
8
votes
4answers
664 views

Human class implementation

I just want an indication as to whether or not I'm on the right track regarding PHP OOP, at least on a basic level. Positive criticism welcome. P.S. Excuse the visuals of the code. This is how I ...
2
votes
1answer
92 views

How can I improve this PHP MySQL rank query?

In my db MySQL, I have a table ranks with many fields, one for each page I want limit access for the user in the menu application with PHP control: <?php if ($row_ranks['padric'] == '1' ) { ...
-3
votes
1answer
47 views

Explain die() in PHP [on hold]

die(json_encode($response -> RequestCallbackResult ? Vein::inst()->getWPPermalink(Vein::inst()->get('dialer_success_redirect')) : false)); What does this mean? Can somebody explain this to ...
4
votes
0answers
25 views

Is this a sensible way of using an IoC container?

I have a Factory class for a queuing system I'm playing around with. Consuming classes only care that they get a particular interface (Job) as a result of calling the factory's load method. Some ...
8
votes
3answers
537 views

Password hashing method

I am having some issue to use PHP5 password_hash() function. My server is not supporting it, so I am using a function to hash. Is this one secure? public function Pass_Hash ($password) { ...
-1
votes
1answer
64 views

Is multiple return statements bad practice? [closed]

When learning computer science at university, I was told to only have one return statement in a method, and use a retval variable where necessary like this: function foo() { $retval = false; ...
4
votes
2answers
44 views

Is there a way to shorten a set of conditionals like this?

I have a long set of IF statements that basically set a null object Value to 0, I feel that because i am doing the same action each time their has to be a simple way to make this allot shorter. It ...
3
votes
2answers
82 views

Parsing annotation

I have implemented code for parsing annotation: /** * @Route(path="sample \n test",code,value,boolean,test) * @access(code=false) * @sample as asdad asd * asd */ function sample() { } ...
0
votes
0answers
25 views

How to add more arrays for link generator? [closed]

I have this code, for payment with PayPal. This is a PHP link generator, but I want to add more amounts/item_name. public function unlock($array=array(),$sandbox=true){ ...
3
votes
1answer
96 views

Spam detection in PHP for comment system

I'am trying to build a PHP/MySQL/jQuery comment system. Off late I started to realize that manual spamming is a serious issue that need to be addressed carefully. So I thought of building a PHP ...
4
votes
1answer
54 views

PHP magic function for accessors and mutators

I have implemented the following PHP magic method behavior to save my time of creating accessor and mutators for properties of any class that extends this base class. I am looking for suggesiongs on ...
5
votes
1answer
65 views

Best Practices concerning Includes and SQL Connect Strings

I'm just starting to learn PHP. I have three random questions about PHP and one question about Code Review. None of them are technical questions ("will this work?"); they're best practices questions ...
7
votes
2answers
114 views

Is this secure for a simple comment system?

<!doctype html> <html> <head> <meta charset="utf-8"> <link rel="stylesheet" type="text/css" href="style.css"> <?PHP //Turn off error reporting (Not Necessary) ...
6
votes
2answers
65 views

Draw the table like 6³ = 3³ + 4³ + 5³ to 100³ = 35³ + 70³ + 85³

I want to draw the table like this: 6³ = 3³ + 4³ + 5³ 9³ = 1³ + 6³ + 8³ 12³ = 6³ + 8³ + 10³ 18³ = 2³ + 12³ + 16³ 18³ = 9³ + 12³ + 15³ 19³ = 3³ + 10³ + 18³ 20³ = 7³ + 14³ + 17³ ..... 100³ = 35³ + 70³ ...
8
votes
1answer
197 views

PHP form review

I saw somewhere on here that it helps reduce spam by adding a dummy input field that you hide with display: none, and like if it's filled out, then it's obviously a bot sending the message. Well, I ...
3
votes
0answers
84 views

Codeigniter Login Controller

Instead of creating an Admin_Controller or MY_Controller I was going to try and just try out all my controllers on requirements that are needed per controller. I know this may seem like additional ...
4
votes
1answer
29 views

Simplifying an associative array()

Would it be better to convert the array in the following code to $langs = array("en", "de", "fr"); and then reusing the values for both $folder and $flag? If so, how then would my foreach (or maybe ...
3
votes
1answer
46 views

PHP class design with methods requiring database access

I've been a procedural PHP programmer for a long time but I'm getting to learn OOP and would like some advice. I'm designing a class which currently is composed mainly of simple getters/setters, but ...
1
vote
0answers
34 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? ...
9
votes
2answers
205 views

Matching script tags with regexes

Like anything that shouldn't be done, I decided to see if it is possible to match <script> tags robustly using regexes in PHP. Since there is no arbitrary nesting, I figured it should at least ...
4
votes
1answer
61 views

PHP wrapper around an API - best practices

Here's a PHP wrapper around a public OAuth2 REST API. I would love to hear your thoughts and comments. Testing was a bit frustrating since I tried for my first time. Not sure if I have done the ...
5
votes
1answer
100 views

Security of a “contact us” form

I have a form, which uses AJAX to send POST data to the following controller method: public function action_sendmail() { $jsonHelper=Loader::helper('json'); $answer = (int) ...
2
votes
1answer
71 views

A File Collector

I'm writing an Object Oriented package and one problem I am trying to solve is a class that will get all php files in a particular directory and instantiate the classes but not abstracts or interface ...
10
votes
2answers
136 views

Review structure of PHP/HTML

I am very new to PHP and I kind of sort of want to create the pages like I would in ASP.NET; it's just the way I am wired. I have been inserting the header/menu using a PHP Include and here is what ...
6
votes
2answers
145 views

Register script security and optimization

function RegisterN() { if($_SERVER['REQUEST_METHOD'] == 'POST'){ if (isset($_POST["password"],$_POST["password1"]) && $_POST["password"]!=$_POST["password1"]) { # Check if password and ...
5
votes
2answers
104 views

Monopoly: Board creation

After initially struggling with the board size, I have now decided the dimension. Please review my code. In the code I am generating HTML code using PHP and MySql. I have not added the database, ...
2
votes
0answers
56 views

Laravel model and controller interaction

I want to know if I'm going about creating and calling two functions from my model to my controller in the simplest and cleanest way. Model: public function getPosts() { $post = ...
1
vote
0answers
41 views

Laravel 4 clean code review of users controller and model, trying to maintain MVC structure

I'd like you to review my attempt at creating an authorization class and let me know if there is re-factoring to be done and/or how I can make the code cleaner and abide by the MVC structure. ...
3
votes
1answer
164 views

Why is my web scraping script so slow?

My script, which is a web scraping script, is very slow, I even needed to put set_time_limit(0); This is the whole http://phpfiddle.org/main/code/9qt-78n I think the problem is here: foreach ...
3
votes
0answers
55 views

System for inputting and monitoring worker shifts

I've been building a system for inputting and monitoring shifts for casual staff, who work across multiple sites with the ability to generate accounting information. I've had some help from Stack ...
1
vote
1answer
27 views

Allow users to add custom queries to Mustache variables

I'm writing an application that will be managed by my team, it uses Mustache.php as template engine. I have a PHP file that makes an array of variables and functions that is passed to the Mustache ...
5
votes
2answers
61 views

Finding missing number from series

This code will accept user input from the command line. The first user can enter the limit of series. e.g: user may enter 5 After that, the user will be prompted for 5 numbers of a series. e.g: 2 ...
5
votes
3answers
79 views

Is this Fibonacci function right?

Is this a correct method of Fibonacci with recursion? function fibb($limit,$first_numer=0,$second_number=1){ echo $first_numer."\n"; echo $second_number."\n"; if($limit > ...
6
votes
3answers
209 views

How can I improve the performance of this concurrent http request loop?

I'm using the rolling curl library to fire http requests for content-length headers of images (we need to know their size to weed out placeholders and low res images). The image urls are stored in a ...
3
votes
1answer
67 views

Query optimization PHP for string concatination

I have an entity RegistrationForm which has a OneToMany-relationship with SurveyAnswer. An answer can either have a collection of FormOptions (when the answer is of type MULTIPLE_CHOICE) or a ...
3
votes
2answers
109 views

PHP Weather class

I am kind of new to object orientation in PHP and I need some experts feedback. This class fetches the weather from this URL. It grabs the weather, temperature and an icon from the current hour. ...
6
votes
1answer
83 views

Review on a PHP login/authentication system

I am currently working on a small website for my scuba diving club, and it needs a "simple" login system to allow members-only features etc. I've been using the php-login-minimal as the base for the ...
4
votes
2answers
80 views

PHP Authentication Security

Can someone look over this? This is the entire authentication file. It's referenced at the beginning of all my catalog editing files to make sure only the specified user is logged in. I want to ...
3
votes
2answers
50 views

Specific PHP Data Access Class review

As part of a fun project to help build my knowledge of PHP. I've written a Data Access Class here to bridge the site to the database. I know there are a lot of posts and articles out there explaining ...
4
votes
2answers
72 views

Handling access to database connection both inside and outside of classes

Is this an OK way to handle access to database connection both inside and outside of classes? I used to include a PHP file -- database.detl.php -- at the very top of my index.php file containing the ...
3
votes
1answer
60 views

Regex to clean text in preparation for word count in PHP

EDIT: Here's my totally-revised PHP... $text = preg_replace("~[^ a-z0-9'-]~"," ",strtolower($INPUT)); for($i=1;$i<strlen($text)-1;$i++) { if(preg_match("~['-]~",$text[$i]) && ( ...
7
votes
2answers
70 views

Are my forms a danger towards code injection?

I'm writing a PHP tutorial and I would like to display some forms where the users could enter values that are displayed in the same webpage, just as a demonstration. The forms do nothing special, ...