PHsPeed Naming Conventions – The Magic of $$


If you put a label component on a form, then by default the name will become label_1:


In this case PHsPeed creates a class name "cust_detail_label_1". The main reason for this is that you can add other classes to this application. Suppose that you have selected a template with a header. This header can also contain a "label_1" which would cause a conflict when running code like:


$label_1->value='something'.


PHP will not be able to decide which variable to use and generates an error. 


So if PHsPeed generates a unique name adding the application name into:  $cust_detail_label_1, then the valid syntax to assign a value to this label would be:


 $cust_detail_label_1->value='myvalue';


But what if you decide for whatever reason, to rename your application? Then you must redo all your code as  $cust_detail_label_1 will have become something different. Besides, if you have to prepend all your variables with the module name, then that becomes a lot of hard and boring work. 


To overcome this, PHsPeed uses the $$ notation, which you can use for all the components that you have put on the form. So


 $cust_detail_label_1->value='myvalue'  will become  $$label_1->value='myvalue';


The code generator will then append the module name while generating code, and if you rename the module, the generator will change the variable names accordingly.