SCPHP Tutorial - Hello World!

This tutorial will show how to create a button that shows the message "Hello World!". The complete source-code is available at the end of the page.

1) Make sure that you already installed SCPHP

If you have not installed SCPHP yet, check the Installation page.

2) Create a new php page and include scripts

Create php page with the following content:

<html>
	<head></head>
	<body>
		<?php
		// Auto load function
		function __autoload( $className )
		{
			require_once( 'SmartClient/'. $className .'.php' );
		}
		
		$scButtons = new ScButtons();
		
		// Include SmartClient scripts
		echo $scButtons->includeScripts();

We first declare the __autoload() function. This isn't a required step, but it is a good idea because it make loading SCPHP classes really easy. You could also use a simple require for the class that you need to use.

After that, we create a new instance of ScButtons class.

And finally, we call includeScripts(). This is a function that automatically include the SmartClient scripts.

3) Create the button

Add the following code to the script:

		// JavaScript function
		$action = "function () { isc.warn( 'Hello World!' ); }";
		
		echo $scButtons->create( 'Click me' , $action );
		
		?>
	</body>
</html>

In this part of the script, we are creating a new button with the following attributes:

  • Title: Click me
  • Action: function () { isc.warn( 'Hello World!' ); }

4) Full source code

Here it is the full source code of the script used on this tutorial:

<html>
	<head></head>
	<body>
		<?php
		// Auto load function
		function __autoload( $className )
		{
			require_once( 'SmartClient/'. $className .'.php' );
		}
		
		$scButtons = new ScButtons();
		
		// Include SmartClient scripts
		echo $scButtons->includeScripts();
		
		// JavaScript function
		$action = "function () { isc.warn( 'Hello World!' ); }";
		
		echo $scButtons->create( 'Click me' , $action );
		
		?>
	</body>
</html>
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.