Wrapping the contents submitted from a textarea in PHP

By default, the texts submitted from a textarea in PHP are displayed in an unbroken single line. For instance, if you have entered the following lorem ipsum text:



It will be displayed as:



This simply tells us that PHP ignores the breaklines posted from a textarea control. This glitch cannot be solved by simply using the WRAP attribute of the textarea tag. Fortunately, PHP provide us with several string functions that can use to solve this problem. One of these functions is the wordwrap function which wraps text depending on the number of character specified by the user. The wordwrap function has the following syntax:

wordwrap(“text to wrap”, columnwidth ,breakline);
For instance:

wordwrap(“Hello world”,5,"<br/>")
For a sample usage of wordwrap in solving the textarea wrapping problem, follow these steps:

1. Start your text editor (Notepad, Notepad++, or Programmers Notepad).
2. Enter the following:

<HTML>
<body>

<!--if the submit button is not yet clicked-->
<?php
if(!$_POST['Submitted'])
:
?>

<!--display our form-->
<FORM ACTION="<?php echo $_SERVER['PHP_SELF']; ?>" Method="POST" >
<br/>
  Enter your message:<br>
<TEXTAREA  WRAp="hard" ROWS="8" COLS="30" NAME="usermsg"></TEXTAREA><br>
<INPUT TYPE="Submit" VALUE="Submit" Name="Submitted"></INPUT> <INPUT TYPE="Reset" VALUE="Clear">
</FORM>


</BODY>
</HTML>


<!--otherwise-->
<?php
else
:
?>


<!--display the text from the textarea-->
<?php
$msg=$_POST['usermsg'];
$wrapmsg=wordwrap($msg,30,"<br/>");
echo "$msg";
endif;
?>
?>

3. Save it as sample.php in the htdocs folder.
4. Launch your web browser.
5. Type the following in the address bar:
http://localhost/sample.php
6. You should now see the following:



7. Try entering a long text in the textarea to see the wordwrap effect. For more information on using the wordwrap string function visit http://www.php.net. That's all!

Changing the Pointer when the mouse hovers an object(Visual F#)

To change the mouse pointer when the mouse hovers an object, use the Cursor property. All form controls in Visual F# has Cursor property. To use the Cursor property, use the following syntax:
Objectvariable.Cursor<-Cursors.CursorStyle
For example:
exitbutton.Cursor<-Cursors.UpArrow
Some CursorStyles values are NoMove2D,Cross and PanSouth. To understand the usage of the Cursor property, try the following example: 1. Click Start>All Programs>Microsoft Visual Studio 2008>Microsoft Visual Studio 2008. 2. Click File>New>Project>Select Visual F# in the project types>Select F# application in the Visual Studio installed templates category. 3. Click the Project menu>Add reference>Click the .Net tab>Locate then double-click System.Windows.Forms. Do step 3 again and this time, select System.Drawing from the .Net tab. 4. Enter the following code after the line “// Learn more about F# at http://fsharp.net “:
// Learn more about F# at http://fsharp.net
//specify the namespace memory location
//of the classes that will be needed in our application
open System
open System.Drawing
open System.Windows.Forms
//create our controls
let ffont=new System.Drawing.Font("Microsoft Sans Serif",9.0F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point)
let myform=new Form(Text="Use Cursors",AutoScaleDimensions=new System.Drawing.SizeF(60.0F, 13.0F),ClientSize=new System.Drawing.Size(207, 133),StartPosition=FormStartPosition.CenterScreen)
let llabel1=new Label(Text="Hand Cursor",AutoSize=true,Location=new System.Drawing.Point(20, 80))
let llabel2=new Label(Text="AppStarting Cursor",AutoSize=true,Location=new System.Drawing.Point(120,80))
//add the controls into our form
myform.Controls.Add(llabel1)
myform.Controls.Add(llabel2)
//add a mousehover and mouseleave events to our controls
//when the mouse hovers our labels, its cursor style,forecolor, and font size will change
//when the mouse leaves our control, the cursor style, label forecolor, and font size will
//return back to default
llabel1.MouseHover.Add(fun disphandcursor->
                  llabel1.ForeColor<-Color.Red
                  llabel1.Cursor<-Cursors.Hand
                  let ffont=new System.Drawing.Font("Microsoft Sans Serif",12.0F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point)
                  llabel1.Font<-ffont)
llabel1.MouseLeave.Add(fun changefontsize->
                  llabel1.ForeColor<-Color.Empty
                  let ffont=new System.Drawing.Font("Microsoft Sans Serif",9.0F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point)
                  llabel1.Font<-ffont)
llabel2.MouseHover.Add(fun dispappcursor->
                  llabel2.ForeColor<-Color.Red
                  llabel2.Cursor<-Cursors.AppStarting
                  let ffont=new System.Drawing.Font("Microsoft Sans Serif",12.0F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point)
                  llabel2.Font<-ffont)
llabel2.MouseLeave.Add(fun retainsfontsize->
                  llabel2.ForeColor<-Color.Empty
                  let ffont=new System.Drawing.Font("Microsoft Sans Serif",9.0F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point)
                  llabel2.Font<-ffont)              
myform.Show()
//executes our application
Application.Run(myform)
5. Click the run icon to execute your application. You should now see an output similar to the following screen shot: