LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 06-18-2013, 04:25 PM   #1
frieza
Senior Member
 
Registered: Feb 2002
Location: harvard, il
Distribution: Ubuntu 11.4,DD-WRT micro plus ssh,lfs-6.6,Fedora 15,Fedora 16
Posts: 3,233

Rep: Reputation: 406Reputation: 406Reputation: 406Reputation: 406Reputation: 406
Is this a valid class definition?


i'm trying to learn a bit about classes in php, and I have created this class
Code:
<?php
class menu_1 {
	/*
	 * variable declarations
	 */
	public $title;
	public $menu;
	/*
	 * block title
	 */
	function get_title() {
		$this->title='STEP 2 - Services you are listed under';
		return $this->title;
	}
	/**
	 * menu definition
	 * @param object $user the user object
	 * @param object $node1 the profile node
	 * @param object $node2 the bio node
	 * @return array the defined menu structure
	 */
	function get_menu($user,$node1,$node2) {
		$this->menu=array(
			0=>array(
				'title'=>'Display Name', //title of link button
				'description'=>'description', // description of button target (directions)
				'base_path'=>'node/'.$node1->nid.'/edit', //base path of link button target
				'object'=>'node1', //object to compare against for completed status
				'field'=>'field_display_name', //field to compare against for completion
				'query'=>'content_complete_fieldname',
			),
		);
		return $this->menu;
	}
}
is this right?
it works, but before I go and dig myself into a hole doing it wrong, i just want to know if i'm doing it right, or if i could do this better.
 
Old 06-19-2013, 02:27 AM   #2
j-ray
Senior Member
 
Registered: Jan 2002
Location: germany
Distribution: ubuntu, mint, suse
Posts: 1,591

Rep: Reputation: 145Reputation: 145
The class is ok so far and we don't know what the site's goals are. So if you want to go on working with PHP you might be interested in using frameworks like ZendFramework or Symfony for the creation of bigger applications. If you just want to get into PHP's object orientation in general you are better off without them.
Cheers, j
 
  


Reply



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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Why can't we access a protected member in a derived class by a base class's object? Aquarius_Girl Programming 5 02-04-2012 10:35 PM
Does making a class a 'friend' make the class' member classes 'friends'? Jusctsch Programming 7 11-17-2011 07:58 PM
C++: Can't link template program with separate files for class definition/declaration Nylex Programming 3 04-15-2007 01:42 PM
Which C++ editor in Linux has the class view/class browser feature imaginationworks Programming 7 05-21-2006 11:09 PM
Defining a non-inline function inside class definition (tm) Programming 6 05-11-2005 09:14 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 01:12 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration