Actions

Talk

Difference between revisions of "PHP essentials"

From Joomla! Documentation

m
m
 
(2 intermediate revisions by one user not shown)
Line 5: Line 5:
 
Yes, you are correct Joe.  Would you like to make the change to the wording?  Thanks.  [[User:Chris Davenport|Chris Davenport]] 19:11, 28 July 2009 (UTC)
 
Yes, you are correct Joe.  Would you like to make the change to the wording?  Thanks.  [[User:Chris Davenport|Chris Davenport]] 19:11, 28 July 2009 (UTC)
  
Arrays -  
+
----
 +
 
 +
--[[User:Eclecticsol|Eclecticsol]] 10:32, 26 January 2011 (UTC)
 +
 
 +
Not familiar with the detail of php (which is why I am here!) but...
 +
 
 +
'''Arrays'''
  
 
"print $my_guitar_heroes[2]; //Access the 2nd element"
 
"print $my_guitar_heroes[2]; //Access the 2nd element"
Line 11: Line 17:
 
To be a pedant - [2] accesses the third element.
 
To be a pedant - [2] accesses the third element.
  
While Loop
+
'''While Loop'''
 +
 
 +
<nowiki>while ( $x <= 10 ) {
 +
print "$x<BR/>";
 +
}</nowiki>
  
 
The while loop illustrated does not increment $x so it will never exit.
 
The while loop illustrated does not increment $x so it will never exit.
 +
 +
Thanks for a very useful intro - trying to understand how to modify a template without breaking the common structure, so there is amountain to climb!

Latest revision as of 05:32, 26 January 2011

It's actually *not* recommended that you start PHP code by "<?php" and end with a "?>" tag. If you are embedding PHP code within HTML markup, you do need to use the closing tag or the file will not parse correctly. However, if the file ends with PHP code instead of HTML markup, it is actually preferred to leave off the final "?>"

I would change that to read "When embedding PHP code within HTML markup, use <?php to start your code and ?> to close it" -jlleblanc

Yes, you are correct Joe. Would you like to make the change to the wording? Thanks. Chris Davenport 19:11, 28 July 2009 (UTC)


--Eclecticsol 10:32, 26 January 2011 (UTC)

Not familiar with the detail of php (which is why I am here!) but...

Arrays

"print $my_guitar_heroes[2]; //Access the 2nd element"

To be a pedant - [2] accesses the third element.

While Loop

while ( $x <= 10 ) { print "$x<BR/>"; }

The while loop illustrated does not increment $x so it will never exit.

Thanks for a very useful intro - trying to understand how to modify a template without breaking the common structure, so there is amountain to climb!