or you can ready my blog :)
http://ragrawal.wordpress.com/2007/11/07/script-for-removing-blank-spaces-before-and-after-php-tags/

On Nov 6, 10:09 pm, bingo <[EMAIL PROTECTED]> wrote:
> hi AD7six, seacloud9, Jon, Mike, francky,
>
> Thanks to all. Finally I was able to get rid of all my spaces. As many
> of you expected, there were many leading and trailing spaces in my
> code and once I removed all of them, everything worked like a charm.
> The good news for other is that I wrote a small script that will
> identify any trailing or leading spaces or new line in your PHP code
> and will inform you about that file. Below is the script that does
> this. Just provide the source location ($sourcepath) of your cakephp
> application and it will recursively go through each file, checking if
> there is any leading or trailing blank spaces.
>
> <?php
> /***********************
> [EMAIL PROTECTED]: Ritesh Agrawal
> [EMAIL PROTECTED]: Identifies php files that contain leading or trailing
> spaces before or after PHP opening or closings tags
> ***********************/
> //Set Source Path
> $sourcepath = "D:/xampp/xampp/htdocs/memento";
>
> //Regex Express to test leading and trailing spaces
> define("PRE", "#^[\n\r|\n\r|\n|\r|\s]+<\?php#");
> define("POST", "#\?>[\n\r|\n\r|\n|\r|\s]+$#");
>
> //Clear the file Status Cache
> clearstatcache();
>
> //============ Code borrowed from php.net ===============
> // Replace \ by / and remove the final / if any
> $root = ereg_replace( "/$", "", ereg_replace( "[\\]", "/",
> $sourcepath ));
> // Touch all the files from the $root directory
> if( false === m_walk_dir( $root, "check", true )) {
>     echo "'{$root}' is not a valid directory\n";
>
> }
>
> // Walk a directory recursivelly, and apply a callback on each file
> function m_walk_dir( $root, $callback, $recursive = true ) {
>     $dh = @opendir( $root );
>     if( false === $dh ) {
>         return false;
>     }
>     while( $file = readdir( $dh )) {
>         if( "." == $file || ".." == $file ){
>             continue;
>         }
>         call_user_func( $callback, "{$root}/{$file}" );
>         if( false !== $recursive && is_dir( "{$root}/{$file}" )) {
>             m_walk_dir( "{$root}/{$file}", $callback, $recursive );
>         }
>     }
>     closedir( $dh );
>     return true;}
>
> //============== end ======================
>
> //If file, checks whether there is any leading spaces before opening
> PHP tag or
> // trailing spaces after closing PHP tag
> function check( $path ) {
>
>     if( !is_dir( $path )) {
>         $fh = file_get_contents($path);
>          if(preg_match(PRE, $fh))
>                echo $path. " -- contains leading spaces \n";
>          if(preg_match(POST, $fh))
>                echo $path . " -- contains trailing spaces \n";
>     }
>
> }
>
> ?>
>
> On Nov 6, 6:21 pm, francky06l <[EMAIL PROTECTED]> wrote:
>
>
>
> > BOMS, mean UTF-8 without BOM (byte order marker), this used under
> > windows to mark UTF-8 files (also UCS-2 etc...). Use an hexadecimal
> > editor and you will notice the 3 bytes marking the UTF-8 at the
> > beginning ..
> > Do not know if it's your problem, but quite classical under windows.
> > You can editor such as Notepad++ to check you file in hexa.
> > Hope this helps
>
> > On Nov 7, 12:14 am, seacloud9 <[EMAIL PROTECTED]> wrote:
>
> > > I don't know in eclipse my guess is it would be associated with your
> > > overall preferences listed under encoding (google that) but you most
> > > likely have space before and after your "<?php" .... "?>"  but do
> > > check your model view controllers all of them.  It is a drag and it
> > > did take me several days to do this myself but it was worth it.
>
> > > On Nov 6, 3:52 pm, bingo <[EMAIL PROTECTED]> wrote:
>
> > > > hi Seacloud9
>
> > > > I am not sure if I understand what do you mean by UTF-8 "BOMS". How
> > > > can verify that. I am using eclipse as my PHP Editor.
>
> > > > Regards,
> > > > Ritesh
>
> > > > On Nov 6, 4:00 pm, seacloud9 <[EMAIL PROTECTED]> wrote:
>
> > > > > I have had this exact same problem it can hold you up for days..
>
> > > > > Make sure you are using UTF-8 "BOMS".
>
> > > > > Make sure tags in Model, Controller, and Views "<?
> > > > > php"............................ "?>"
> > > > > Have no spaces after or before them NONE.  I found one in the cake
> > > > > folder in the app model.  You have six spaces this is literally the
> > > > > cause of your frustrations.  You should check every model, view, and
> > > > > controller..  It does suck but it is what is causing your problem.
>
> > > > > On Nov 6, 1:54 pm, bingo <[EMAIL PROTECTED]> wrote:
>
> > > > > > hi AD7six,
>
> > > > > > I tried putting header in default layout for RSS, but didn't work. I
> > > > > > didn't recieve that output buffer already started at XYZ. The only
> > > > > > error that I am getting is "Invalid XML Declaration -  Line: 1
> > > > > > Character: 6". I also tried putting header command in controller
> > > > > > class, but that also didn't work. :-(
>
> > > > > > //views/layouts/rss/default.ctp
> > > > > > <?php echo header("Cache-Control: no-cache, must-revalidate"); ?>
> > > > > > <?php
> > > > > > echo $rss->header();
> > > > > > echo '<channel>';
> > > > > > echo '<link>', Router::url('/', true), '</link>';
> > > > > > echo '<language>en-us</language>';
> > > > > > echo '<pubDate>', date("D, j M Y H:i:s", gmmktime()) . ' GMT', '</
> > > > > > pubDate>';
> > > > > > echo '<generator>Memento</generator>';
> > > > > > echo '<managingEditor>[EMAIL PROTECTED]</managingEditor>';
> > > > > > echo '<webMaster>[EMAIL PROTECTED]</webMaster>';
> > > > > > echo '<docs>http://blogs.law.harvard.edu/tech/rss</docs>';
> > > > > > echo $content_for_layout;
> > > > > > echo '</channel>';
> > > > > > ?>
>
> > > > > > This is frustrating :-(
> > > > > > isn't there any magic command that will automatically remove all the
> > > > > > trailing and leading spaces ?
>
> > > > > > Regards,
> > > > > > Ritesh
>
> > > > > > On Nov 6, 10:07 am, AD7six <[EMAIL PROTECTED]> wrote:
>
> > > > > > > On Nov 6, 2:01 pm, bingo <[EMAIL PROTECTED]> wrote:
>
> > > > > > > > hi all,
>
> > > > > > > > I tried what Jon suggested. But still getting space before my 
> > > > > > > > xml
> > > > > > > > declaration :-( ...this is killing me...isn't there a good way 
> > > > > > > > to
> > > > > > > > debug this problem. Searching on the forum, I have realized 
> > > > > > > > that many
> > > > > > > > people struggle with this.
>
> > > > > > > "you could try issuing a header as the first line of your layout 
> > > > > > > and
> > > > > > > see where it complains output already
> > > > > > > started. "
>
> > > > > > > there are many threads because it's a common problem (or a common
> > > > > > > mistake).
>
> > > > > > > You'll find it in the end ;).
>
> > > > > > > AD- Hide quoted text -
>
> > > > > - Show quoted text -- Hide quoted text -
>
> > - Show quoted text -- Hide quoted text -
>
> - Show quoted text -


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to