TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 01-16-2008, 07:21 PM   #1 (permalink)
Alan @ CIT
Member of the Month
The Frequenter
Member of the Month Top Contributor 
 
Alan @ CIT's Avatar
 
Join Date: Apr 2005
Location: South UK
Posts: 483
Thanks: 51
Alan @ CIT is on a distinguished road
Box Last 5 lines of PHP code that you wrote

Hey all,

No reason at all for this thread, just pure bordem, but I'd like to know what the last 5 lines of PHP code where that you wrote.

(the 5 lines don't include comments or whitespace, just actual code)

Be honest, don't edit them at all (well, remove sensitive info) then post them here

Here's mine:

PHP Code:
        // Pull the entry for the given date from the database
        
$items = new Item();

        
$where $items->getAdapter()->quoteInto('publish = ?'$date);
        
$item $items->fetchRow($where);

        
// Check we got a result
        
if ($item === NULL)
        { 
Alan
Send a message via MSN to Alan @ CIT
Alan @ CIT is offline  
Reply With Quote
Old 01-16-2008, 07:31 PM   #2 (permalink)
The Addict
Top Contributor Good Samaritan 
 
Join Date: Jan 2008
Location: USA
Posts: 217
Thanks: 16
RobertK is on a distinguished road
Default

Err, I don't have five lines, unless you count whitespace. I was working on my own MVC framework, others are too advanced for me yet, and this is my last few lines:
PHP Code:
  public function dispatch() {
    
$page $_GET['page'] or 'index';
    
$cmd  $_GET['cmd']  or 'index';
  } 
We could post once a week or so with our last five lines, it'd sure make an interesting thread, wouldn't it?
__________________
Programmers are in a race with the Universe to create bigger and better idiot-proof programs, while the Universe is trying to create bigger and better idiots. So far the Universe is winning. - Rich Cook
RobertK is offline  
Reply With Quote
Old 01-16-2008, 07:36 PM   #3 (permalink)
Moderateur
RegEx Guru PHP Guru Top Contributor Advanced Programmer 
 
Salathe's Avatar
 
Join Date: Apr 2007
Posts: 1,393
Thanks: 5
Salathe is on a distinguished road
Default

Not very interesting or insightful, but there are my last five lines!

PHP Code:
    else
    {
        
$opml[count($opml) - 1]['count'] = 0;
    }

Salathe is offline  
Reply With Quote
Old 01-16-2008, 07:41 PM   #4 (permalink)
Alan @ CIT
Member of the Month
The Frequenter
Member of the Month Top Contributor 
 
Alan @ CIT's Avatar
 
Join Date: Apr 2005
Location: South UK
Posts: 483
Thanks: 51
Alan @ CIT is on a distinguished road
Default

Quote:
Originally Posted by RobertK View Post
We could post once a week or so with our last five lines, it'd sure make an interesting thread, wouldn't it?
I'll go for that - will need reminding though as I can barely remember what I'm doing each day, let alone a week in advance :)

Alan
Send a message via MSN to Alan @ CIT
Alan @ CIT is offline  
Reply With Quote
Old 01-16-2008, 08:59 PM   #5 (permalink)
The Addict
 
Join Date: Nov 2007
Posts: 264
Thanks: 2
TlcAndres is on a distinguished road
Default

PHP Code:

       
public function __query($sql)
        {
                
$this->varScope->queryCount++;
                
$query odbc_exec($this->varScope->connectionID,$sql);
                if (
$query != false
Adding an odbc driver to my database DB
TlcAndres is offline  
Reply With Quote
Old 01-16-2008, 09:18 PM   #6 (permalink)
La Vida es Sueño
Advanced Programmer Top Contributor 
 
Wildhoney's Avatar
 
Join Date: Sep 2007
Location: Oldham
Posts: 2,280
Thanks: 90
Wildhoney is on a distinguished road
Default

php Code:
interface TalkPHP_Newsletter_Interface
{
    public function getEmail($szEmailAddress);
    public function addEmail($szEmailAddress);
    public function removeEmail($szEmailAddress);
}

Just created myself an interface
__________________
The man who comes back through the Door in the Wall will never be quite the same as the man who went out.
Send a message via AIM to Wildhoney Send a message via MSN to Wildhoney Send a message via Yahoo to Wildhoney
Wildhoney is offline  
Reply With Quote
Old 01-16-2008, 10:19 PM   #7 (permalink)
The Frequenter
Zend Certified 
 
Join Date: Sep 2007
Location: Denmark
Posts: 352
Thanks: 8
Kalle is on a distinguished road
Default

Part of Tuxxedo Forums; in /includes/functions_forum.php (construct_forumbits()):

PHP Code:
            $forumdata $tuxxedo->datastore->getDatastore('forumdata');

            if(!
sizeof($forumdata))
            {
                
tuxxedo_error($phrase['no_forums']);
            }

            foreach(
$forumdata as $forum)
            {
                
$forumdata[$forum['id']]['subforums'] = explode(' '$forum['subforums']);
            } 
For those whos interested in the final source, then ill update my api docs in a moment so its avaible from:
Tuxxedo Software Development
Send a message via MSN to Kalle Send a message via Skype™ to Kalle
Kalle is offline  
Reply With Quote
Old 01-16-2008, 10:22 PM   #8 (permalink)
The Addict
 
webtuto's Avatar
 
Join Date: Dec 2007
Location: morocco
Posts: 221
Thanks: 19
webtuto is on a distinguished road
Default

PHP Code:
require_once (SMARTY_DIR."Smarty.class.php");
  
   
$smarty = new Smarty;
   
$smarty->compile_dir"$fixpath/libs/compile";
   
$smarty->template_dir"$fixpath/template/gray";
  
  
?> 
bcz im learning about smarty
__________________
Send a message via MSN to webtuto Send a message via Yahoo to webtuto Send a message via Skype™ to webtuto
webtuto is offline  
Reply With Quote
Old 01-16-2008, 10:33 PM   #9 (permalink)
Moderateur
RegEx Guru PHP Guru Top Contributor Advanced Programmer 
 
Salathe's Avatar
 
Join Date: Apr 2007
Posts: 1,393
Thanks: 5
Salathe is on a distinguished road
Default

Yay more lines of code.

PHP Code:
$fetcher        = new TalkPHP_Latest_Articles();
$view           = new View('rss');
$view->articles $fetcher->get_articles();
$view->render();
exit; 
An interface to the newest articles here on TalkPHP so that I can subscribe to an RSS in order to keep up to date -- seeing as there isn't one already provided!
Salathe is offline  
Reply With Quote
Old 01-16-2008, 11:14 PM   #10 (permalink)
The Acquainted
Upcoming Programmer 
 
CMellor's Avatar
 
Join Date: Sep 2007
Location: Leeds, UK
Posts: 141
Thanks: 6
CMellor is on a distinguished road
Default

php Code:
)) or die(mysql_error());
    // Fetch
    $row = mysql_fetch_array($query);
   
    return $row['username'];
}
// Register function
$smarty->register_function('getUsernameById', 'getUsernameById');
__________________
Not quite a n00b...
CMellor is offline  
Reply With Quote
Old 01-16-2008, 11:16 PM   #11 (permalink)
Wizard
Top Contributor 
 
Village Idiot's Avatar
 
Join Date: Sep 2007
Posts: 1,299
Thanks: 17
Village Idiot is on a distinguished road
Default

PHP Code:
$id $data->post("id");

mysql_query("DELETE FROM `items` WHERE `id` = '$id'") or die(mysql_error());
echo 
"Item deleted";
?> 
__________________

Village Idiot is offline  
Reply With Quote
Old 01-17-2008, 04:03 PM   #12 (permalink)
The Contributor
 
buggabill's Avatar
 
Join Date: Jan 2008
Location: Maine, USA
Posts: 92
Thanks: 2
buggabill is on a distinguished road
Default

This is at the end of an xajax function, in a controller, in CodeIgniter, on an intranet application that I am working on at work... How many prepositional phrases can we squeeze into one sentence?

PHP Code:
        }
    }
        
    
$objResponse->addAssign('div_formwrap''innerHTML'$innerHTML);
    
    return 
$objResponse;

__________________
-- Bill
"Why is it drug addicts and computer aficionados are both called users?" -Clifford Stoll
buggabill is offline  
Reply With Quote
Old 01-19-2008, 11:16 PM   #13 (permalink)
Alan @ CIT
Member of the Month
The Frequenter
Member of the Month Top Contributor 
 
Alan @ CIT's Avatar
 
Join Date: Apr 2005
Location: South UK
Posts: 483
Thanks: 51
Alan @ CIT is on a distinguished road
Default

Bill, out of interest, what do you think of CodeIgniter compared to other frameworks like Cake or Zend?

Another 5 lines from me - parts of my Zend Framework Application Generator project:

PHP Code:
        $this->view->currentStep = ($_SESSION['totalSteps'] == 4);
        
$this->view->totalSteps $_SESSION['totalSteps'];

        
// Display the correct form based on the appType
        
if ($_SESSION['appType'] == 'modular')
        {
            
$this->render('actions-modular'); 
Alan
Send a message via MSN to Alan @ CIT
Alan @ CIT is offline  
Reply With Quote
Old 01-19-2008, 11:29 PM   #14 (permalink)
how quixotic are you?
 
ETbyrne's Avatar
 
Join Date: Dec 2007
Location: Lapeer, MI
Posts: 445
Thanks: 37
ETbyrne is on a distinguished road
Default

Some code from the install.php file in my new CMS that is to be released on the 26th. ;)

PHP Code:
mysql_query("INSERT INTO users VALUES ('$admin', '$admin_pass', '$admin_email', '$first', '$last')");

$profile 'This is your profile. Click the link below this box to edit it. :)';

$file fopen("bin/users/$admin.txt","w");
fwrite($file"$profile");
fclose($file); 
__________________
Dingo Web Systems > http://www.dingocode.com
My Website > http://www.evanbot.com
ETbyrne is offline  
Reply With Quote
Old 01-19-2008, 11:48 PM   #15 (permalink)
Moderateur
RegEx Guru PHP Guru Top Contributor Advanced Programmer 
 
Salathe's Avatar
 
Join Date: Apr 2007
Posts: 1,393
Thanks: 5
Salathe is on a distinguished road
Default

For my signature :)

PHP Code:
/* Output the finished image */
header('Content-Type: image/gif');
imagegif($im$dir.'cache_img.gif');
imagegif($im);
imagedestroy($im);


// Write cache
file_put_contents($dir.'cache_hash.txt'$cache_hash); 
Salathe is offline  
Reply With Quote
Old 01-20-2008, 12:13 AM   #16 (permalink)
The Frequenter
Newcomer 
 
xenon's Avatar
 
Join Date: Dec 2007
Location: Bucharest, Romania
Posts: 438
Thanks: 3
xenon is on a distinguished road
Default

Testing my session management cookie-based system.

PHP Code:
$this->Input Registry::get'input' );
$this->DB Registry::get'database' );

$cookies['session_id'] = $this->Input->ReadCookie'sid' );

if( 
$cookies['session_id'] === null )
{
    
$this->init_new_session();

__________________
I have optimistic thoughts, even though sometimes (if not always) life's a bitch.
xenon is offline  
Reply With Quote
Old 01-20-2008, 02:51 AM   #17 (permalink)
The Contributor
 
buggabill's Avatar
 
Join Date: Jan 2008
Location: Maine, USA
Posts: 92
Thanks: 2
buggabill is on a distinguished road
Default

Quote:
Bill, out of interest, what do you think of CodeIgniter compared to other frameworks like Cake or Zend?
I have not really had a chance to use other frameworks. I am most certainly curious about them.

Code Igniter is really my first framework. I like it! The whole MVC world, once I was able to wrap my noggin around it, is a blast to work in! CI was a good intro for me to MVC. The documentation is clear enough, and the community is pretty nice over there.

I would like to try another framework out such as Cake or Zend, but I would have to say, for the couple apps I am working on right now, CI is doing just fine.

I have also wanted to try PHP on Trax. I have seen what can be done in Ruby on Rails and it interests me immensely!
__________________
-- Bill
"Why is it drug addicts and computer aficionados are both called users?" -Clifford Stoll
buggabill is offline  
Reply With Quote
Old 01-20-2008, 04:25 AM   #18 (permalink)
The Frequenter
Newcomer 
 
xenon's Avatar
 
Join Date: Dec 2007
Location: Bucharest, Romania
Posts: 438
Thanks: 3
xenon is on a distinguished road
Default

CI has a little bit of a CakePHP feeling (Cake is lighter, but at the same time better structured). Zend is the best object oriented framework for PHP that I have ever seen. And it's truly a framework. It doesn't do anything else but provide you with helping libraries. It's not a working system (which is good in my oppinion). After all, it has been developed by the company that supports the PHP development so...
__________________
I have optimistic thoughts, even though sometimes (if not always) life's a bitch.
xenon is offline  
Reply With Quote
Old 01-20-2008, 07:23 AM   #19 (permalink)
The Frequenter
Prolific Welcomer Upcoming Programmer 
 
Join Date: Sep 2007
Posts: 360
Thanks: 24
Haris is on a distinguished road
Default

PHP Code:
  $title get_option('ajax_comments_spy_widget_title');
  
$before_widget '<li class="widget ajax_comments_spy_widget" id="ajax-comments-spy">';
  
$after_widget '</li>';
  if(empty(
$before_title)) { 
__________________
Necessity is the mother of invention.

My blog

Last edited by Haris : 01-20-2008 at 11:05 AM.
Haris is offline  
Reply With Quote
Old 01-20-2008, 10:13 AM   #20 (permalink)
Alan @ CIT
Member of the Month
The Frequenter
Member of the Month Top Contributor 
 
Alan @ CIT's Avatar
 
Join Date: Apr 2005
Location: South UK
Posts: 483
Thanks: 51
Alan @ CIT is on a distinguished road
Default

That's never 5 lines Mr Haris!

Alan
Send a message via MSN to Alan @ CIT
Alan @ CIT is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT. The time now is 03:51 PM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design