While creating a module I had a look at the News module. In News/action.defaultadmin.php I found this code snippet:
if( $this->CheckPermission( 'Modify Templates' ) ) {
echo $this->StartTab('summary_template', $params);
{
echo ''.$this->Lang('title_available_templates').'';
$this->_AdminCreateTemplateList($id,$returnid,
'summary',
'default_summary_template_contents',
'summary_template',
'current_summary_template',
$this->Lang('title_summary_template'));
}
echo $this->EndTab();
My question is what this brace is doing:
echo $this->StartTab('summary_template', $params);
{
Thanks,
Rob
[solved] brace in a php contruction???
-
- Forum Members
- Posts: 75
- Joined: Wed Aug 20, 2008 2:08 pm
- Location: Nijmegen, the Netherlands
[solved] brace in a php contruction???
Last edited by Anonymous on Sat Jul 25, 2009 9:07 pm, edited 1 time in total.
Re: brace in a php contruction???
I think what he's saying is that there's no "conditional" statement to warrant the "{".
Nullig
Nullig
-
- Forum Members
- Posts: 75
- Joined: Wed Aug 20, 2008 2:08 pm
- Location: Nijmegen, the Netherlands
Re: brace in a php contruction???
IndeedNullig wrote: I think what he's saying is that there's no "conditional" statement to warrant the "{".
Nullig

I’ve had a look at the PHP documentation but there is nothing about this kind of use.
Rob
Last edited by robbedoes on Mon Jul 20, 2009 7:57 am, edited 1 time in total.
Re: brace in a php contruction???
AFAIK the curly braces are (besides control structures) mainly used for complex syntax in strings.
I use it a lot when I'm using object methods in sql queries, for example:
(to prevent having to do something like:)
(or:)
When they're used around a some lines of code like in this case I think it's just to show that the lines/statements form a "code block"/statement group (for readability purposes).
D
I use it a lot when I'm using object methods in sql queries, for example:
Code: Select all
$sql = "SELECT * FROM {$config->GetTable()} WHERE some_field = {$someobject->GetSomeValue()}";
Code: Select all
$sql = "SELECT * FROM " . $config->GetTable() . " WHERE some_field = " . $someobject->GetSomeValue()";
Code: Select all
$table = $config->GetTable();
$value = $someobject->GetSomeValue();
$sql = "SELECT * FROM $table WHERE some_field = $value;
Regards,statements can be grouped into a statement-group by encapsulating a group of statements with curly braces
D
Last edited by Anonymous on Mon Jul 20, 2009 12:03 pm, edited 1 time in total.
-
- Forum Members
- Posts: 75
- Joined: Wed Aug 20, 2008 2:08 pm
- Location: Nijmegen, the Netherlands
Re: brace in a php contruction???
I am coding PHP for years but never saw this handy construction.
Thank you Dee for the kind explanation.
Best regards,
Rob
Thank you Dee for the kind explanation.
Best regards,
Rob