Archive

Posts Tagged ‘microsonic’

Thoughts or Comments: Re-opening the Hosting Branch

October 20th, 2009

Hey everyone!

As many of you may or may not know, Microsonic used to be a hosting company. From 2005-2008 I ran the site as “Microsonic Hosting.” In 2009, however, I decided to make it a more specialized place consisting of my thoughts and sharing my skills with others. Today, however, an idea ran across my head: re-open the hosting branch. So in this topic, I’ll take you through my head a bit more.

Well, what does this entail? The mere thought makes one wonder what would happen to the current site. Well, it would remain the same. As I mentioned, it would be a “branch” of Microsonic Development. I actually run “Microsonic Development” as a freelance programming company, so I may even revamp this to being much more than simply a blog! A hosting company that is not run by C/O’s who know very little about what they’re selling, but rather a professional selling services to another professional. Keeping in mind the reason I closed up shop in the first place, however, is also very important.

Due to lack of business and trying to keep prices low, costs built up and I ended up taking a loss on the whole project unfortunately. Not that I am in it to solely make a profit, but just like for everyone else, finances are tight. But then again, in retrospect it is important to think about what caused the collapse. My lack of advertising was the ultimate beast that did it in in the first place. All clients I had were extremely happy and very upset when I announced the initial closing of the company, however, had more people known about the satisfaction perhaps more members would have joined.

So now, as I continue to ponder my own thoughts, what are you personal thoughts? Perhaps I should specialize? Rather than web hosting, perhaps I will provide shell or VPS hosting? Let me know what you think! Your thoughts are, as usual, very helpful for me as they inspire my decisions about how to proceed in certain actions and what kinds of articles to write!

Regards,
Dennis M.

admin News, Other , ,

Updates soon… Hold tight!

May 3rd, 2009

It’s been a while since I’ve had a nice fleshed out article. So, I’m going to be creating another PHP article soon about something most users will hopefully find very interesting. Generally, I get great feedback from you guys on what you like and dislike about my articles which I value and greatly appreciate. Keep sending me requests and I will get to them.

Also, I’m obviously for hire for anyone who just wants work done rather than to learn about it. So if you have work, feel free to contact me at dennis [at] microsonic [dot] org or via MSN at admin [at] microsonic [dot] org. But again, just to learn some new things, I’m always to help for free by creating an article on here!

Regards,
Dennis M.

admin News , , ,

What are PHP Classes and How to Use Them

April 16th, 2009

So some users have been e-mailing me asking me, “What are PHP classes? Why not just use functions?” Well, you could technically just use functions but it makes things messy and insecure. Let me explain. Classes, to oversimplify things a bit, are organizational units within PHP or any other Object Oriented Programming (OOP) language such as C++.

These organizational units, or Classes, hold common functions that you program. They can be used in numerous ways from defining __construct() for everything, or having a private function …() so that nothing outside of members within the class can access the function.

Well, you know what they say; good leading is leading by example. So we’re going to write a quick class and break it down!

<?php
/**
 * Simple class by Dennis M.
 *
 */

// Class definition
class Test
{
	// Define variables here if any.
	var $test = NULL;

	/**
	 * Now, we have two ways to define our constructor.
	 * we can use function __construct() OR we can use
	 * function Test(). If __construct() and Test() are both
	 * used, then the class will use __construct. If not, it
	 * will look for Test(). If neither are defined, we don't
	 * have a constructor XD
	 *
	 */
	function __construct(){
		/**
		 * Define actions in here that will
		 * take place for every function in the class!
		 * If you're not using a DB wrapper, then
		 * you can even define your mysql_connect()
		 * and mysql_select_db() in here so the functions
		 * don't have to do it later!
		 *
		 */
	}

	/**
	 * This next function allows us to print out information
	 * that is returned. Now, we're going to use two functions in here.
	 * The first function that is going to be defined is the public function
	 * for what we want to do. The second function, the check function,
	 * is going to be called within this function, but can only be called by a
	 * script like this because it's private and this function is within
	 * the class.
	 *
	 * It sounds much more confusing than it is in practice :)
	 * let's take a look.
	 *
	 * NOTICE: function text($param='val'). This defines an optional variable
	 *	   when calling the script later. E.g.: text("hello"); or $text();
	 *	   will both work. The first one will use "hello" and the second one
	 *	   will use the default value.
	 *
	 * @return string
	 *
	 */
	function text($say='test'){
		/**
	 	 * Let's run the check first.
		 * The check is a bool function so
		 * when we check for a response, we'll
		 * look for true or false.
		 *
	 	 * Note, because the function is within the
		 * class and it is separate from this one,
		 * we call it using the $this-> operator.
		 *
		 */
		if($this->check($say) != true){
			return "Could not find "".$say."" in the variable \$test.";
		}

		/**
		 * That was our only check. Now, let's
		 * return a success message if
		 * we got passed that!
		 * Realize that 'return' in a function is similar
		 * to an 'exit' in non-function programming.
		 *
		 * Also, return always returns with a value unless
		 * you are creating a VOID function, in which case
		 * you would just use return and no value would come back.
		 *
	 	 */
		return "Success! We found "".$say."" in the variable \$test!";
	}

	/**
	 * Here is the private function we were talking about.
	 *
	 * Private let's us know that no object outside the class "Test"
	 * can use this function.
	 *
	 * @return boolean
	 *
	 */
	private function check($say){
		/**
		 * We defined this variable earlier as
		 * null. Define it as string 'test'
		 * which is what the preceding function
		 * uses by default.
		 *
		 */
		$test = "test";
		if($say != $test){
			return false;
		}
		// That was the only check :)
		return true;
	}
}

// Now we have ended the class but in order to initiate it we
// must define an operator. This is how:
$testclass = new Test;

// Now, we must use pointers to call to functions!
// This will NOT work.
print "Test 1 should fail: ".$testclass->text('w00t!')."<br /><br />";

// This WILL work
print "Test 2 should succeed: ".$testclass->text()."<br />OR
<br />".$testclass->text('test')."<br /><br />";

// This WILL NOT work
print "Test 3 should fail: ";
print $testclass->check('test');

?>

Now I’ve pretty much explained most of what I’m going to cover within the code in the long comments. Now this tutorial is mainly an introduction to classes, but I’d like to leave you guys with a little something more. I’m going to leave this off at the beginning of the “intermediate” level. It’s very difficult to cram EVERYTHING about classes into one post because the possibilities are infinite. So, I’m going to get you started right now on learning more about them and the only way to begin achieving that infinite knowledge is to keep working with them!

You can add the following to the previous code (but make sure it is BEFORE test3 because the error will stop the rest of the script from processing from that point on)

class Test2 extends Test
{
	/**
	 * Note the "extends Test" defined after "class Test2"
	 * This makes Test2 an extension of "Test". In Test2
	 * you are now able to call all functions from Test
	 * using the $this-> operator except for the private
	 * functions. Those are still reserved for the Test class
	 * only.
	 *
	 */
	function w00t(){
		return $this->text();
	}
}

// Define second "test" class
$testclass2 = new Test2;

// This WILL work
print "Test 4 should succeed: ".$testclass2->w00t();

And that about wraps this one up! As usual, for those of you who would rather just download the code, it’s available here:
Classes Tutorial

2 more topics to cover, so get to e-mailing me on what you want to see after those!

Regards,
Dennis M.

admin PHP , , , , , ,

The Next Big Update: What to Look For

April 6th, 2009

Hello everyone,

Just an update here talking about the next big update that I have planned for you guys! But first, I’d like to remind you all of the recent “PHP Password + Salt + Encryption” Tutorial that I recently posted yesterday! It is ready for you all to go take a look. So anyone interested in that, might want to go take a look at that ;)

Alright, back to business. So this next update will be broken up. It’s going to be HUGE! Over the next week (in any order, not necessarily how I have them posted here) you should expect extensive posts about the following to be up:

  • Simple C/C++ Memory Management Tutorial
  • The Importance of RSS Feed and What It Is
  • Creating PHP Classes and How to Use Them Effectively
  • What is CGI/Perl and How Could it be Useful
  • The Basics of Working within a Linux Terminal

Like I said, I’m going to be trying to get these all ready and posted for you guys within the next week or two. Also, as arbitrary as these articles may seem, they come from all of you who have written to me asking for these things. These are among the most popular articles, so please feel free to drop me an e-mail and ask more questions that I could answer!

The e-mail is: dennis@microsonic.org

Thanks again,
Dennis M.

admin News , , , , , , , , , ,