php-windows Digest 18 Jun 2012 13:56:00 -0000 Issue 4053

Topics (messages 30912 through 30915):

Re: Printing large pieces of HTML markup inside the <?php ?> tags..?
        30912 by: Keith Davis
        30913 by: Jacob Kruger

Yet another question - this one related to dynamically generating/passing 
images through to output/browser
        30914 by: Jacob Kruger

Object instantiation/referral conventions/alternatives
        30915 by: Jacob Kruger

Administrivia:

To subscribe to the digest, e-mail:
        php-windows-digest-subscr...@lists.php.net

To unsubscribe from the digest, e-mail:
        php-windows-digest-unsubscr...@lists.php.net

To post to the list, e-mail:
        php-wind...@lists.php.net


----------------------------------------------------------------------
--- Begin Message ---
Are you referring to the HEREDOC syntax?

http://www.php.net/manual/en/language.types.string.php#language.types.string.syntax.heredoc

Sent from my iPhone 4s

On Jun 14, 2012, at 12:10 AM, "Jacob Kruger" <ja...@blindza.co.za> wrote:

> Came across some code/script/markup similar to the following syntax, and not 
> too sure if it falls under a specific template framework, etc.?:
>
> <?php
>    print <<<HTML
>    <form method="POST" action="attendance.php">
>    <table class="defaultTbl">
>        <tr>
>            <th colspan="2">Attendance Register Search</th>
>        </tr>
>        <tr>
>            <td class="caption">$sDivisionName</td>
>            <td>
> HTML;
> ?>
>
> That's just a piece of it, so don't worry about HTML markup missing pieces - 
> more interested in print <<<HTML...HTML; part..?
>
> Stay well
>
> Jacob Kruger
> Blind Biker
> Skype: BlindZA
> '...fate had broken his body, but not his spirit...'


This message (including any attachments) may contain confidential or otherwise 
privileged information and is intended only for the individual(s) to which it 
is addressed. If you are not the named addressee you should not disseminate, 
distribute or copy this e-mail. Please notify the sender immediately by e-mail 
if you have received this e-mail by mistake and delete this e-mail from your 
system. E-mail transmission cannot be guaranteed to be secured or error-free as 
information could be intercepted, corrupted, lost, destroyed, arrive late or 
incomplete, or contain viruses. The sender therefore does not accept liability 
for any errors or omissions in the contents of this message or that arise as a 
result of e-mail transmission. If verification is required please request a 
hard-copy version from the sender.

www.pridedallas.com


--- End Message ---
--- Begin Message --- Yup, that's it - HEREDOC syntax is what was referring to - thanks - and, here's a better version of some output - since you don't seem to be able to specifically include PHP code itself within delimiters, although you can output variables, etc.:

<?php
$var1 = "hulloWorld";
print <<<HTML
   <table align="center" border="1">
   <tr>
    <th colspan="2">$var1</th>
   </tr>
   <tr>
   <th>Caption</th><td>column</td>
   </tr>
   </table>
HTML;
?>

Stay well

Jacob Kruger
Blind Biker
Skype: BlindZA
'...fate had broken his body, but not his spirit...'

----- Original Message ----- From: "Keith Davis" <keithda...@pridedallas.com>
To: <php-wind...@lists.php.net>
Sent: Thursday, June 14, 2012 7:18 AM
Subject: Re: [PHP-WIN] Printing large pieces of HTML markup inside the <?php ?> tags..?


Are you referring to the HEREDOC syntax?

http://www.php.net/manual/en/language.types.string.php#language.types.string.syntax.heredoc

Sent from my iPhone 4s

On Jun 14, 2012, at 12:10 AM, "Jacob Kruger" <ja...@blindza.co.za> wrote:

Came across some code/script/markup similar to the following syntax, and not too sure if it falls under a specific template framework, etc.?:

<?php
   print <<<HTML
   <form method="POST" action="attendance.php">
   <table class="defaultTbl">
       <tr>
           <th colspan="2">Attendance Register Search</th>
       </tr>
       <tr>
           <td class="caption">$sDivisionName</td>
           <td>
HTML;
?>

That's just a piece of it, so don't worry about HTML markup missing pieces - more interested in print <<<HTML...HTML; part..?

Stay well

Jacob Kruger
Blind Biker
Skype: BlindZA
'...fate had broken his body, but not his spirit...'


This message (including any attachments) may contain confidential or otherwise privileged information and is intended only for the individual(s) to which it is addressed. If you are not the named addressee you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately by e-mail if you have received this e-mail by mistake and delete this e-mail from your system. E-mail transmission cannot be guaranteed to be secured or error-free as information could be intercepted, corrupted, lost, destroyed, arrive late or incomplete, or contain viruses. The sender therefore does not accept liability for any errors or omissions in the contents of this message or that arise as a result of e-mail transmission. If verification is required please request a hard-copy version from the sender.

www.pridedallas.com


--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



--- End Message ---
--- Begin Message ---
Based on this page:
http://webcheatsheet.com/php/dynamic_image_generation.php

The following seems to operate/run, but, although can't 'see' if the image 
looks right, the windows explorer image preview status bar seems to reckon 
there's an issue with it, and paint refuses to open the image file..?

<?php 
//Send a generated image to the browser 
create_image(); 
exit(); 

function create_image() 
{ 
    //Let's generate a totally random string using md5 
    $md5 = md5(rand(0,999)); 
    //We don't need a 32 character long string so we trim it down to 5 
    $pass = substr($md5, 10, 5); 

    //Set the image width and height 
    $width = 100; 
    $height = 20;  

    //Create the image resource 
    $image = ImageCreate($width, $height);  

    //We are making three colors, white, black and gray 
    $white = ImageColorAllocate($image, 255, 255, 255); 
    $black = ImageColorAllocate($image, 0, 0, 0); 
    $grey = ImageColorAllocate($image, 204, 204, 204); 

    //Make the background black 
    ImageFill($image, 0, 0, $black); 

    //Add randomly generated string in white to the image
    ImageString($image, 3, 30, 3, $pass, $white); 

    //Throw in some lines to make it a little bit harder for any bots to break 
    ImageRectangle($image,0,0,$width-1,$height-1,$grey); 
    imageline($image, 0, $height/2, $width, $height/2, $grey); 
    imageline($image, $width/2, 0, $width/2, $height, $grey); 
 
 //send it as an attachment
 header('Content-Disposition: attachment; filename="dynamic.jpg"');
    //Tell the browser what kind of file is come in 
    header("Content-Type: image/jpeg"); 

    //Output the newly created image in jpeg format 
    ImageJpeg($image); 
    
    //Free up resources
    ImageDestroy($image); 
} 
?>

Also tried rather using ImageCreateFromPNG() and ImageCreateFromJPEG functions 
to just load an image from an existing file, and then output it to the browser, 
but same issue:

<?php 
//Send a generated image to the browser 
create_image(); 
exit(); 

function create_image() 
{ 

    //Create the image resource 
$image = ImageCreateFromJPEG("./images/it490.jpg");
 //send it as an attachment
 header('Content-Disposition: attachment; filename="dynamic.jpg"');
    //Tell the browser what kind of file is come in 
    header("Content-Type: image/jpeg"); 

    //Output the newly created image in jpeg format 
    ImageJpeg($image); 
    
    //Free up resources
    ImageDestroy($image); 
} 
?>


Same thing in terms of image file seeming corrupted, while if rename it to 
.txt, and then open it in like notepad, it does seem to have binary 
data/character jumbled up in it..?


Effectivelfy, I actually want to take some template images, add text to them in 
various fonts/layouts, and then effectively place them in PDF files, and have 
got some similar code seeming to work already, but wanted a bit more control 
over image files, retrieval of dimensions, etc., but here's a sample that seems 
to be working already:
http://blindza.co.za/postcards/pdfVersion.php

Just comes down to that if I want to make a bit more of a dynamic use of 
different image templates, I might want to do a bit more than just render them, 
etc.

Thoughts..?

Jacob Kruger
Blind Biker
Skype: BlindZA
'...fate had broken his body, but not his spirit...'

--- End Message ---
--- Begin Message ---
Sorry if subject line is off-topic/off-subject, but, again, comes down to not 
100% sure about what am asking...:)

Either way, along with these sort of wrapper/parent type objects am now meant 
to make use of, the naming convention used to refer to them is like the 
following:
Security::functionName();
Database::anythingYouLike;

Those could be referring to either a function, a method, or a property, and 
think the objects Security and Database are being instantiated in the sort of 
page framework/wrapper I am referring to in the top part of a PHP page, but, 
not sure exactly how they are defined, if it's a server/naming convention 
setting that means they then don't need to specifically make use of the $ sign 
before the name of these objects, whether it's to do with them having being 
included/instantiated once off, globally, etc., etc., and the issue with trying 
to investigate something like this by searching around the 'net is that certain 
search terms aren't the best when it comes to searching around google for 
things like this...LOL!

What am trying to put together right about now are my own sort of dummy 
versions of these objects, so that can do a bit more testing/trying out code on 
my side before uploading pages to server, etc., but anyway.

Thoughts, etc.?

TIA

Jacob Kruger
Blind Biker
Skype: BlindZA
'...fate had broken his body, but not his spirit...'

--- End Message ---

Reply via email to