· Important links:
PHPDN's General Posting Guidelines - Should be read first thing.
Asking Smart Questions - How and how not to ask questions.
Boards Search System - Should be used prior to asking questions. Alot of the questions have allready been asked and answered.
PHP Starter Pack - Fundamental PHP Know-How - Tutorial is aimed at people taking their first steps with php. (By McGruff)
· Tweaks during post:
Short/Long PHP tags in code:
With the above quote in mind, take a moment and think about on how you write code. If you use the short-tag version when typing, you must realize that the code might not work properly at all times. If I personally would copy-n'-paste code using short-tags, the result would be unpleasant because of the setting above.php.ini wrote:; Allow the <? tag. Otherwise, only <?php and <script> tags are recognized.
; NOTE: Using short tags should be avoided when developing applications or
; libraries that are meant for redistribution, or deployment on PHP
; servers which are not under your control, because short tags may not
; be supported on the target server. For portable, redistributable code,
; be sure not to use short tags.
short_open_tag = Off
I, as many others, use the long-tag version due to the fact that this works everywhere. If you spend hours/days/months creating your perfect application you would not like it to break if you switch hosting server... Just a friendly warning.
Code: Select all
<? echo 'foo'; ?> <- Might generate issues.
<% echo 'foo'; %> <- Might generate issues.
<?= 'foo'; ?> <- Might generate issues.
<?php echo 'foo'; ?> <- Works.
Please, use the
Code: Select all
YOUR PHP CODE HERE[ /syntax][/b] tags around php code posted in the forum and [b][code ]YOUR RESULT HERE[ /code ][/b] as preferred tags to show examples of output, code results. For plain SQL queries (not embedded into the php code) use the [b][syntax="sql" ]YOUR SQL QUERY HERE[ /syntax][/b]
Not just is this posts easier to read, it will also make people actually read the post instead of ignoring it. For more indepth reading on these custom tags, continue reading the thread or skip down directly to [url=http://forums.devnetwork.net/viewtopic.php?t=21171#131836]feyd's post on the subject[/url].
[b]Bad Example, no tags:[/b]
<?php
echo 'Hi!';
?>
[b]Good Example, with tags:[/b]
[syntax=php]<?php
echo 'Hi!';
?>
My code is:
Code: Select all
<?php
echo 'Hi!';
?>
Code: Select all
Hi!
Code: Select all
CREATE TABLE `tracker` (
`PkEcode` int(4) NOT NULL DEFAULT '0',
`Date_txt` date NOT NULL DEFAULT '0000-00-00',
`Team` varchar(30) NOT NULL DEFAULT '',
`CourseCode` varchar(30) NOT NULL DEFAULT '',
`Activity` varchar(100) NOT NULL DEFAULT '',
`Slides` int(5) NOT NULL DEFAULT '0',
`Time` decimal(5,2) DEFAULT NULL,
`Recordcount` int(12) NOT NULL AUTO_INCREMENT,
PRIMARY KEY (`Recordcount`)) TYPE=MyISAM AUTO_INCREMENT=165 ;
INSERT INTO `tracker` VALUES (4001, '2004-06-22', 'Audio', 'Project-1', 'Audio Editing', 12, '7.00', 145);
INSERT INTO `tracker` VALUES (4002, '2004-06-22', 'Audio', 'Project-1', 'Audio Editing', 12, '8.00', 146);
INSERT INTO `tracker` VALUES (4002, '2004-06-24', 'Audio', 'Project-1', 'Audio Cutting', 34, '10.00', 147);
INSERT INTO `tracker` VALUES (4003, '2004-06-22', 'Development', 'Project-1', 'Animation', 15, '8.00', 148);
INSERT INTO `tracker` VALUES (4004, '2004-06-24', 'Development', 'Project-1', 'Animation', 15, '8.00', 149);
INSERT INTO `tracker` VALUES (4005, '2004-06-22', 'QC', 'Project-1','QC-Level1', 24, '4.00', 154);
INSERT INTO `tracker` VALUES (4006, '2004-06-24', 'QC', 'Project-1','QC-Level2', 24, '4.00', 155);