[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 298
  • Last Modified:

Simple ASP webpage to PHP webpage conversion

Can someone convert this ASP webpage to a PHP page please? I need to call this barcode from a .php file where ASP is not enabled. The .aspx will need to say the same.
Thanks
<html>
<body>
<p>This web page uses PHP code to create a barcode.</p>
<% @ LANGUAGE = VBScript %>
<% BarcodeData = "123456789012" %>
<p><img src="<%="http://www.bcgen.com/demo/linear-dbgs.aspx?Barcode=" & BarcodeData %>"</p>
</body>
</html>

Open in new window

0
tncode
Asked:
tncode
1 Solution
 
zicevaCommented:
That's about it ...

<html>
<body>
<p>This web page uses PHP code to create a barcode.</p>
<?php
$BarcodeData = "123456789012";
?>
<p><img src="http://www.bcgen.com/demo/linear-dbgs.aspx?Barcode=<?=$BarcodeData;?>"></p>
</body>
</html>

Open in new window

0
 
ropennerCommented:
The PHP file can be static since your example doesn't have any variable that can actually change.

I suspect the code you have is more complicated than this and there is a ASP->PHP converter script that works for simple cases such as this

http://asp2php.mikekohn.net/
<html>
<body>
<p>This web page uses PHP code to create a barcode.</p>
<p><img src="http://www.bcgen.com/demo/linear-dbgs.aspx?Barcode=123456789012"></p>
</body>
</html>

Open in new window

0
 
Ray PaseurCommented:
The example from ziceva will work if you have short-open tags enabled.  Many installations turn off short-open tags because of the risk of collisions with XML strings.
http://php.net/manual/en/ini.core.php

I find the HEREDOC notation to be especially useful for things like this.  It lets you separate the logic from the presentation.
http://php.net/manual/en/language.types.string.php#language.types.string.syntax.heredoc

See http://www.laprbass.com/RAY_temp_tncode.php?q=12345 for an example.  In the code snippet you can follow the variable $q to see how it works.

Best to all, ~Ray
<?php // RAY_temp_tncode.php
error_reporting(E_ALL);


// THIS IS THE PROGRAM LOGIC.  IT CREATES ALL THE VARIABLES WE NEED IN THE HTML OUTPUT STREAM
// RECEIVE THE BARCODE DATA FROM THE URL STRING OR SET A DEFAULT VALUE
$q = (!empty($_GET["q"])) ? $_GET["q"] : '0000';


// AFTER THE PROGRAM LOGIC HAS COMPLETED, WE USE THE VARIABLES IN THE HTML
// CREATE THE HTML STRING USING HEREDOC NOTATION
$htm = <<<HTM
<html>
<title>The Barcode for $q</title>
<body>
<p>This web page doe not actually use PHP code to create a barcode. It sends <b>$q</b> to an external service.</p>
<p><img src="http://www.bcgen.com/demo/linear-dbgs.aspx?Barcode=$q"></p>
</body>
</html>
HTM;


// PRODUCE THE BROWSER OUTPUT
echo $htm;

Open in new window

0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now