Here's my situation: I've got a PHP base class that appears something similar to this:

class Table title = "table"

  public function selectAllSQL()Choose * FROM " . self::$table_title

  



Along with a subclass that's such as this:

class MyTable stretches Table title = "my_table"



Regrettably, after i do:

MyTable::selectAllSQL()

I recieve:

"Choose * FROM table"

rather than my preferred result,

"Choose * FROM my_table"

It appears like this can be done in php 5.3 using late static bindings, but can there be in whatever way I'm able to make this happen behavior in PHP 5.2.x?

Not necessarily. This is exactly why LSB was put into 5.3. Instantiation is what you want, within this place, together with a singleton.

Instantiate the category of cause is definitely an option!

<?php

abstract class Table title

public function selectAllSQL() title





class MyTable stretches Table title = 'my_table'



$my_table = new MyTable()

echo $my_table->selectAllSQL() // Will output "Choose * FROM my_table"

If you need to keep static than reimplementation is the only method to use PHP < 5.3:

<?php

abstract class Table title = 'table'

public static function selectAllSQL() title)



public static function selectAllSQLTable($table) 



class MyTable stretches Table title = 'my_table'

public static function selectAllSQL() title)





class MyOtherTable stretches Table title = 'my_other_table'

public static function selectAllSQL() title)





echo MyTable::selectAllSQL() // Will output "Choose * FROM my_table"

echo MyOtherTable::selectAllSQL() // Will output "Choose * FROM my_other_table"

Will it be a choice to instantiate the classes?

Yeh late static binding is what you want. You may be on PHP 5.3 right now. This is how it will look then:

Change

class Table title = "table"

  public function selectAllSQL()Choose * FROM " . self::$table_title

  



to

class Table title = "table"

  public function selectAllSQL()Choose * FROM " . static::$table_title