LC Script in PHP File

Peter W A Wood peterwawood at gmail.com
Sun Nov 23 02:09:57 EST 2014


You should be able to use file_get_contents in PHP to do what you want. Though it will take longer to get the results from LiveCode than it would from PHP.

Here is an example:

PHP file:
<!DOCTYPE html>
<html>
	<head>
		<meta http-equiv="content-type" content="text/html;charset=utf-8" />
		<title>Testing Getting Results From Website</title>
	</head>
	<body>
		<p>
		  <?php 
		    $livecode_returned = file_get_contents('http://localhost/webtest.lc');
		    echo($livecode_returned);
		  ?>
		</p>
	</body>
</html>

LiveCode file:
<?lc
    if $_GET["name"] <> "" then
      put "Peter" into tName
   else
      put "World" into tName
   end if
    put header "Content-Type: text/html"
    put "<html>"
    put "<head>"
    put "<title>My LiveCode Server Test Page</title>"
    put "</head>"
    put "<body>"
    put "<h1>My LiveCode Server Test Page</h1>"
    put "<p>Hello" && tName && "from LiveCode Server</p>"
    put "<p>The date is" && the internet date & "</p>"
    put "<p>" & the second char of "12345" & "</p>"
    put "</body>"
    put "</html>"
?>

Results:
My LiveCode Server Test Page

Hello World from LiveCode Server

The date is Sun, 23 Nov 2014 14:27:24 +0800

2

Hope this helps.

Peter

> On 23 Nov 2014, at 13:29, Nakia Brewer <Nakia.Brewer at westrac.com.au> wrote:
> 
> Hi,
> 
> I am in the process of putting a web app together using the UserFrosting system as a starting point.
> I am slowly getting the hang of the framework and am now wishing to start using LC Server to do some backend crunching to render the pages. (Im not picking up PHP as fast as I hoped!)
> 
> The UserFrosting system bases all of its page contents in PHP Files by design.
> 
> For example the index file is index.php
> 
> My question is, am I able to call LC functions from within a PHP file?
> 
> For example, in the below page (which is a PHP file)
> Red content...
> 
> <?php
> /*




More information about the use-livecode mailing list