Welcome Guest, Not a member yet? Register   Sign In
Documentation 2.2.0
#1

Hei guys!

I was really looking forward to learn CI and now that it seems to be live again I will start to build my personal apps using it Smile

I've read almost all the documentation on CI 2.2.0 and I must say it is amazing! Despite the awesome job I would suggest to have a topic dedicated to improve it (please move this to the correct thread if it already exists elsewhere since I'm new to the forum).

------------------------------------------------------------------------------------------
Broken links in Table of Contents
Additional Resources
Community Forums (leads to 404)
Community Wiki (leads to 404)

------------------------------------------------------------------------------------------
Doubts about Short Open Tags
Source: http://www.codeigniter.com/user_guide/ge...guide.html
Short Open Tags

Always use full PHP opening tags, in case a server does not have short_open_tag enabled.

INCORRECT:
<? echo $foo; ?>

<?=$foo?>

CORRECT:
<?php echo $foo; ?>
------------------------------------------------------------------------------------------
But according to:
http://www.codeigniter.com/user_guide/ge...e_php.html
CI supports automatic conversion of short tags in case it isn't supported... So I am confused. Should we always use full PHP opening tags or not?

Automatic Short Tag Support

Note: If you find that the syntax described in this page does not work on your server it might be that "short tags" are disabled in your PHP ini file. CodeIgniter will optionally rewrite short tags on-the-fly, allowing you to use that syntax even if your server doesn't support it. This feature can be enabled in your config/config.php file.
------------------------------------------------------------------------------------------
Reply
#2

I started a thread about improving the documentation. I suggested it could be a community effort, with various people contributing whatever they thought could improve it, and I submitted a couple contributions myself. But the thread wasn't made into a sticky, so it's at the bottom of the page. You can see it here.
http://forum.codeigniter.com/thread-189.html

Specifically about short tags, PHP now supports the short form by default, so there's no more "in case a server does not have short_open_tag enabled."

Feel free to use <?= $variable ?> with abandon! Smile
(but not <? $variable ?> because <? is for XML.

In fact, Rasmus Lerdorf, creator of the PHP language and still a big influence in its development, endorses using them. The rule that you must never ever use short tags is just one of those made-up things that became rules, like "never end a sentence with a preposition." Check this out.
http://programmers.stackexchange.com/que...tag-in-php
Reply
#3

The CodeIgniter project specifies to NOT use short tags, as our coding convention.They are LEGAL to use, but we do NOT encourage it.

From the [url=http://php.net/manual/en/language.basic-syntax.phptags.php]PHP manual[/utl]:
Quote:PHP also allows for short open tag <? (which is discouraged since it is only available if enabled using the short_open_tag php.ini configuration file directive, or if PHP was configured with the --enable-short-tags option).

This is just one of our "made-up things", but contributions to the codebase will not be accepted if they include short tags.
James Parry
Project Lead
Reply
#4

The documentation is, and always has been, a community effort, done through pull requests to the code repo.
The sources used to build the user guide are in the "user_guide_src" folder.

There were some interesting ideas in the thread you reference, and I will comment there.
James Parry
Project Lead
Reply
#5

(12-31-2014, 04:18 PM)jlp Wrote: The CodeIgniter project specifies to NOT use short tags, as our coding convention.

Okey dokey!  Big Grin

Coding conventions are useful and I follow them except when I inadvertently don't because I didn't read closely enough. I got some global replacing to do.
Reply
#6

(This post was last modified: 12-31-2014, 08:44 PM by Ivo Miranda.)

I understand the conventions and I won't argue with that. My doubt is just that in:
http://www.codeigniter.com/user_guide/ge..._open_tags
it is very clear that it we must use always use full PHP opening tags. (I assumed it will be a convention to use everywhere).

But here:
http://www.codeigniter.com/user_guide/ge...e_php.html
we are encouraged to use short tags: 'To minimize the PHP code in these files, and to make it easier to identify the code blocks it is recommended that you use PHPs alternative syntax for control structures and short tag echo statements. If you are not familiar with this syntax, it allows you to eliminate the braces from your code, and eliminate "echo" statements.'

Unless the convention is to use full tags everywhere except in the views but I think that should be specified in this last link so that there is no confusion. In my opinion the documentation wants us to use full tags everywhere except to echo things in the views but I think that more clarification wouldn't hurt here.

Should I submit to git the broken links?
Reply
#7

From the PHP manual, about short open tag :


Quote:echo also has a shortcut syntax, where you can immediately follow the opening tag with an equals sign. Prior to PHP 5.4.0, this short syntax only works with the short_open_tag configuration setting enabled.
Source: http://php.net/manual/en/function.echo.php



Quote:This directive also affected the shorthand <?= before PHP 5.4.0, which is identical to <? echo. Use of this shortcut required short_open_tag to be on. Since PHP 5.4.0, <?= is always available.
Source: http://php.net/manual/en/ini.core.php#in...t-open-tag


So, since PHP 5.4, the short echo tag is always available, even if the short tags are not enabled.
Reply
#8

(01-01-2015, 01:15 PM)includebeer Wrote: So, since PHP 5.4, the short echo tag is always available, even if the short tags are not enabled.

...and the supported version of PHP for CI 2.2 is 5.1.6. Therefore, the information is still relevant.
Reply
#9

(01-07-2015, 10:54 AM)mwhitney Wrote: ...and the supported version of PHP for CI 2.2 is 5.1.6. Therefore, the information is still relevant.

Then it depend if your working on a private project or not. For a private project your only concern is the version running on your own servers.
Reply
#10

Well... For private projects of course that running is the main concern.

I am very new to the community but in my opinion the documentation should always follow the same logic. In one place of the documentation I feel that it's good to use short tags because even if server doesn't support CI has a way to make it work and in another place it is explicit that we should always use full tag.

As I said before I think the authors meant that in views we should use short tags and everywhere else we should use full tags. Since the CI documentation is very good and almost never leaves the user room for interpretation I think in this topic it should also be more explicit so that no user might have other interpretations.

By the way... really nice nickname @includebeer lol Smile
Reply




Theme © iAndrew 2016 - Forum software by © MyBB