Jump to content


Check out our Community Blogs

Vladimir

Member Since 05 Nov 2010
Offline Last Active Feb 16 2011 12:02 PM
-----

Posts I've Made

In Topic: Smarty: Is it worth using?

09 December 2010 - 03:52 AM

Check main page of Twig and compare listed features with Smarty.

In Topic: Smarty: Is it worth using?

08 December 2010 - 03:31 AM

The best template engine available for PHP is Twig: Twig - The flexible, fast, and secure template engine for PHP . At the second place goes JustPlainPHP. To find a prove you can check what template engines use two most popular PHP frameworks: Symfony2 and Zend Framework.

In Topic: python login help

08 December 2010 - 03:22 AM

You have to wrap login code to function and then call that function whenever you need:

def login():
    # here goes login code

if answer != 'correct':
    login()

As I said in my first answer you have to grab book for beginners and learn programming basics. I can't explain you everything in a few sentences.

In Topic: Formatting HTML

06 December 2010 - 02:38 PM

What PHP code you have in templates that you can't format nicely? Generally there should be just one-liners:

<ul>
<?php foreach (get_items() as $item): ?>
  <li><a href="<?= url_for('item', $item) ?>"
         target="_blank"><?= $item ?></a></li>
<?php endforeach; ?>
</ul>

I format both HTML and PHP using 2 space as indentation, but I don't use much PHP in templates (generally just conditions and loops).

You can also take a look at Twig - definitely best template engine for PHP.

In Topic: python login help

05 December 2010 - 12:31 PM

You need infinitive loop (look at the forum logo :) until user enters right password:

while True: # infinitive loop
    # code stays almost unmodified
    login = raw_input('Login: ')
    password = raw_input('Password: ')

    if login == 'root' and password == 'root':
        # user entered right login and password
        # break the loop
        break
    else:
       print('Invalid login or password. Please try again.')

# user reaches this point only if he entered right login and password
print('Hello, root')

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download