Jump to content


Member Since 31 Mar 2005
Offline Last Active Dec 07 2014 09:26 PM

Posts I've Made

In Topic: Alternatives to $_GLOBALS

21 November 2014 - 11:11 PM

I would rather not pass each given property on a need to use basis, but just pass the whole object.

Why? The only reason to do this is laziness. It is making your code tightly coupled to whatever this "god" object is.

A controller has no interest in your connection settings for instance.

Objects should be passed their dependencies (and only their dependencies) at construction time.

Most frameworks handle this in an easy to manage manor by providing a configurable dependency injection container which allows you to configure how objects are to be created.

In Topic: Rookie needs help - filtering path?

17 November 2014 - 06:03 AM

You don't need a regex unless you actually need to match a pattern..

<?php if (substr_count($path, '/') > 2) { echo "Directories too deep"; }

In Topic: Cronjob and insert content in site

08 November 2014 - 05:52 PM

Your script is going to have to write to the index.php file.
Easy way is to make a template file with a searchable tag you can do a find and replace on like: {{replace_text}}
You open the file, search and replace the tags you want.
Will need to set the permissions on that file to make it writeable.
Then use functions like:
preg_match() or str_replace()

Why would you edit the index.php file? PHP is a programming language, you can use it to dynamically display data from different data sources. Having cron dynamically alter the PHP "script" is ridiculous.

Instead, have your cron job put the data somewhere PHP can easily access it (like a database) and then write some logic into your php script to retrieve this data and display it.

In Topic: Efficient portable PHP development environment?

03 November 2014 - 07:22 AM

Define "portable".

In Topic: Where is anti-formatting performed?

01 November 2014 - 09:45 PM

There should be zero business logic in controllers. They are nothing but a very thin layer between http and your domain.

Cheap Linux VPS from $5
SSD Storage, 30 day Guarantee
1 TB of BW, 100% Network Uptime