Numbering

Bar discussions . Talk about everything not only php !. Guests are welcome here , forum registration is not required.

Moderators: egami, macek, gesf

User avatar
admin
Site Admin
Site Admin
Posts: 122
Joined: Wed Apr 17, 2002 7:49 am
Location: Rome

Thu May 05, 2005 11:33 pm

Code: Select all

<?php
$path = "whatever the path to the file is";
$fp = fopen($path, 'r');
do //we loop until there is no data left
{
       $data = fread($fp, 8192);
       if (strlen($data) == 0) break;
       $content .= $data;
     } while (true);
$content_encode = chunk_split(base64_encode($content));
$message .= $content_encode . "\n";
$message .= "--" . $boundary . "\n";


$headers  = "From: \"Me\"<me@here.com>\n";
$headers .= "MIME-Version: 1.0\n";
$headers .= "Content-Type: multipart/mixed; boundary=\"$boundary\"";
mail('myAddress@hotmail.com', 'Email with attachment from PHP', $message, $headers);
?>


Alexei , fantastic work! :)

User avatar
Virtuoso
php-forum Active User
php-forum Active User
Posts: 267
Joined: Mon Jul 21, 2003 7:05 am
Contact:

Fri May 06, 2005 4:44 am

You could make it so that it takes of all the line breaks before and after the code.

User avatar
Alexej Kubarev
Site Admin
Site Admin
Posts: 2213
Joined: Fri Mar 05, 2004 7:15 am
Location: Täby, Stockholms län
Contact:

Fri May 06, 2005 6:19 am

well... i think its quite useless... and plus: user can decide himself..
if he will put a line break after a start of the code tag: there will be a linebreak..[/code]
Best Regards,
Alexej Kubarev
-------------------------------
Zend Certified Engineer
Image Image

User avatar
WiZARD
Moderator
Moderator
Posts: 1240
Joined: Thu Jun 20, 2002 10:14 pm
Location: Ukraine, Crimea, Simferopol
Contact:

Thu May 12, 2005 6:11 am

Alexei Kubarev wrote:well... i think its quite useless... and plus: user can decide himself..
if he will put a line break after a start of the code tag: there will be a linebreak..[/code]

as you see this post
http://www.php-forum.com/p/viewtopic.php?p=24577#24577
you can see what color highlighting is missed...
Reason:
1 too big
2 different remarks.
"Sex,Drugs and Rock&Roll " replaced at "Sucks,Bugs and Plug&Play";
Image

User avatar
Alexej Kubarev
Site Admin
Site Admin
Posts: 2213
Joined: Fri Mar 05, 2004 7:15 am
Location: Täby, Stockholms län
Contact:

Thu May 12, 2005 6:22 am

NO no and no: you need to use <?php ?> or <? ?> tags for highliting to work ^^
it WILL work if you put them ^^
Best Regards,
Alexej Kubarev
-------------------------------
Zend Certified Engineer
Image Image

User avatar
Alexej Kubarev
Site Admin
Site Admin
Posts: 2213
Joined: Fri Mar 05, 2004 7:15 am
Location: Täby, Stockholms län
Contact:

Thu May 12, 2005 6:26 am

here you go with some example:

Code: Select all

<?php
# Hi Wiz!

function func($param){
   //test function
   $var = $param . "adding text";
   return $var;
}

/*This one is highlighted*/
?>



Code: Select all

# Hi again Wiz!

function func2($param2){
   //test function
   $var2 = $param2 . "adding text again";
   return $var2;
}

/*
This one is NOT highlighted
*/
Best Regards,
Alexej Kubarev
-------------------------------
Zend Certified Engineer
Image Image

User avatar
WiZARD
Moderator
Moderator
Posts: 1240
Joined: Thu Jun 20, 2002 10:14 pm
Location: Ukraine, Crimea, Simferopol
Contact:

Thu May 12, 2005 6:36 am

гы!
"Sex,Drugs and Rock&Roll " replaced at "Sucks,Bugs and Plug&Play";
Image

User avatar
Alexej Kubarev
Site Admin
Site Admin
Posts: 2213
Joined: Fri Mar 05, 2004 7:15 am
Location: Täby, Stockholms län
Contact:

Thu May 12, 2005 7:09 am

^^
Best Regards,
Alexej Kubarev
-------------------------------
Zend Certified Engineer
Image Image

User avatar
WiZARD
Moderator
Moderator
Posts: 1240
Joined: Thu Jun 20, 2002 10:14 pm
Location: Ukraine, Crimea, Simferopol
Contact:

Thu May 12, 2005 7:18 am

Alexei Kubarev wrote:^^

what exactly this ^^ mean?
"Sex,Drugs and Rock&Roll " replaced at "Sucks,Bugs and Plug&Play";
Image

User avatar
Alexej Kubarev
Site Admin
Site Admin
Posts: 2213
Joined: Fri Mar 05, 2004 7:15 am
Location: Täby, Stockholms län
Contact:

Thu May 12, 2005 7:22 am

(^_^) or ('._.) pick one :D just a smiley
Best Regards,
Alexej Kubarev
-------------------------------
Zend Certified Engineer
Image Image

User avatar
gesf
Moderator
Moderator
Posts: 1716
Joined: Sun Dec 29, 2002 5:03 am
Location: Portugal / Sweden
Contact:

Thu May 12, 2005 11:31 am

Hey Alex, try this lil' code in the hilite script:

Code: Select all

<?php

if (substr($code, 0, 2) != '<?' && strpos($code, '<?') == false) {
   $code_plus_block = "<?php\n$code\n?" . ">";
        // Or...  with the html entities
}

?>
So it will automatically add the php blocks to the code if they doesn't exists.
Not sure if it will work.
Sincerely,
Gonçalo "gesf" Fontoura

gesf.org | sessionstart.com | urlms.com

User avatar
Alexej Kubarev
Site Admin
Site Admin
Posts: 2213
Joined: Fri Mar 05, 2004 7:15 am
Location: Täby, Stockholms län
Contact:

Thu May 12, 2005 11:57 am

its a bad idea..as sometimes people add html or simply SQL and therefore we dont want to add those tags..however thanx for the idea... or did you have other things iny our mind that im not aware of?
Best Regards,
Alexej Kubarev
-------------------------------
Zend Certified Engineer
Image Image

User avatar
gesf
Moderator
Moderator
Posts: 1716
Joined: Sun Dec 29, 2002 5:03 am
Location: Portugal / Sweden
Contact:

Thu May 12, 2005 11:15 pm

That's true :o
Ok, but there's always the possibility to add the blocks, hilite it and delete the blocks.
It will be hilited and without the blocks ;)
Well, just an idea! Also it's not that important!
Sincerely,
Gonçalo "gesf" Fontoura

gesf.org | sessionstart.com | urlms.com

User avatar
swirlee
Moderator
Moderator
Posts: 2257
Joined: Sat Jul 05, 2003 1:18 pm
Location: A bunk in the back
Contact:

Fri May 13, 2005 9:35 am

gesf wrote:Ok, but there's always the possibility to add the blocks, hilite it and delete the blocks.
It will be hilited and without the blocks ;)


No, that would confuse the highlighter a lot. I agree that this isn't really necessary -- if people want their code highlighted correctly, they'll use the PHP tags. If not, tough luck.
Image

User avatar
Alexej Kubarev
Site Admin
Site Admin
Posts: 2213
Joined: Fri Mar 05, 2004 7:15 am
Location: Täby, Stockholms län
Contact:

Fri May 13, 2005 9:40 am

Totally agree with Swirlee.
by the way: always wanted to ask: what does "swirlee" mean?
Best Regards,
Alexej Kubarev
-------------------------------
Zend Certified Engineer
Image Image

Post Reply