Getting Started

This site is named “NewChk” for a reason. That’s all you need to know to run the program.

After the chk class is available in your project (see installation), you call “new chk” anywhere in the PHP development file your currently working on, like so:

new chk($variable);

That’s all there is to it. I made it simple, because I don’t like a lot of typing. This will make a new instance of the Chk class. The “new” key word, you should be familiar with, as this is the way you make instances of all your classes, nothing “new” here, pun intended.

The class will create a new instance of the chk object, that will then check the variable, $variable, for value and type, and take care of everything else to output the $variable information in an aesthetically pleasing manner in your browser window when you access your web page.

You can call NewChk as many times as you want in one file, each occurrence will be outputted to your browser window in the order of appearance in your development file.

For example, if you’re working on a new web page, in the newpage.php file, and you use “new chk($variable);” in the file, then when you go to http://localhost/newpage.php in your browser, the chk($variable) output will be displayed in your browser window at the top of the page, followed by the rest of the page content.

To simplify NewChk’s usage, you can string variables together in one call to new chk(), like so:

new chk($var1, $var2, $var3, $var4);

Each variable will then be outputted to your web page under development in your browser window.  This is great for checking all the variables in a foreach loop or conditional statement.

One gotcha is if you call new chk() in a controller that then goes to a view file, you may  not see the output of new chk(), because you’ve gone to another file.  The same thing would happen if you used an echo or print_r command.  The solution is to put a return; after the call to new chk(), like so:

new chk($variable);

I was recently working in a very large model file, and couldn’t figure how to get my new chk variable to the browser window.  Here’s another solution to not having a view page,  that you can use with any PHP script.

new chk($variable);

This will exit the application and put up a screen in your browser with just your new chk variables in your browser window.  If you hit the back button on your browser, you’re back to your application.

I have gradually gravitated to using the “exit” as my my preferred way to call newchk, as I always get my output.  I have an ” ncx” hot key set up using AutoHotKey in Windows, so all I do is type “ncx” hit the space bar, and all the newchk  text including the “exit” is outputted, I copy and paste my $variable in between the parenthesis, and hit run.  It’s quick.

See the rest of the documentation, for an image of each data types output, along with how that output was called, and a detailed explanation of the information that the output contains.