[eluser]imn.codeartist[/eluser]
[quote author="Shouvik-S-Mazumdar" date="1262817076"]Ok i am from C# background and while coding in Codeigniter can i use the oops to pass param..
like suppose i have
function write_blog($title,$body,$date)
{
// some implementations
}
instead of that
class Blog
{
public string title;
public string body;
public string date;
}
// re writing the write method
function write_blog(Blog b)
{
// some implementations
}
Similarly if i want to read Blogs do i have a collection object like
List<Blog>
====
am sorry of this is a basic PHP function... do help me out ..would be gr8ful
thnx[/quote]
This code will help your problem
Code:
class Blog
{
var $title;
var $body;
var $date;
}
function write_blog($blog)
{
echo $blog->title ."<br/>";
echo $blog->body."<br/>";
echo $blog->date."<br/>";
}
Implementation
$blog=new Blog();
$blog->title="this is title";
$blog->body="this is Body";
$blog->date=date('Y-m-d');
write_blog($blog);
Since PHP has not generic collection type
you can store into arrays
for example
Code:
$blog_coll=array($blog1,$blog2);
or
$blog_coll[0]=$blog1;
$blog_coll[0]=$blog2;