Signup/Sign In

Answers

All questions must be answered. Here are the Answers given by this user in the Forum.

The reason you should leave off the php closing tag (?>) is so that the programmer doesn't accidentally send extra newline chars.

The reason you shouldn't leave off the php closing tag is because it causes an imbalance in the php tags and any programmer with half a mind can remember to not add extra white-space.

So for your question:

Is there another good reason to skip the ending php tag?

No, there isn't another good reason to skip the ending php tags.

I will finish with some arguments for not bothering with the closing tag:

People are always able to make mistakes, no matter how smart they are. Adhering to a practice that reduces the number of possible mistakes is (IMHO) a good idea.

PHP is not XML. PHP doesn't need to adhere to XMLs strict standards to be well written and functional. If a missing closing tag annoys you, you're allowed to use a closing tag, it's not a set-in-stone rule one way or the other.
3 years ago
Yes, PHP_EOL is ostensibly used to find the newline character in a cross-platform-compatible way, so it handles DOS/Unix issues.

Note that PHP_EOL represents the endline character for the current system. For instance, it will not find a Windows endline when executed on a unix-like system.
3 years ago
You probably need to put the timezone in a configuration line in your php.ini file. You should have a block like this in your php.ini file:
***
[Date]
; Defines the default timezone used by the date functions
; php.net/date.timezone
date.timezone = America/New_York
***
If not, add it (replacing the timezone by yours). After configuring, make sure to restart httpd (service httpd restart).
3 years ago
I'd probably do something like this:
***

class Student
{
public function __construct() {
// allocate your stuff
}

public static function withID( $id ) {
$instance = new self();
$instance->loadByID( $id );
return $instance;
}

public static function withRow( array $row ) {
$instance = new self();
$instance->fill( $row );
return $instance;
}

protected function loadByID( $id ) {
// do query
$row = my_awesome_db_access_stuff( $id );
$this->fill( $row );
}

protected function fill( array $row ) {
// fill all properties from array
}
}

?>
***
Then if i want a Student where i know the ID:
***
$student = Student::withID( $id );
***
Or if i have an array of the db row:
***
$student = Student::withRow( $row );
***
Technically you're not building multiple constructors, just static helper methods, but you get to avoid a lot of spaghetti code in the constructor this way.
3 years ago
The error message indicates that a MySQL connection via socket is tried (which is not supported).

In the context of Laravel (artisan), you probably want to use a different / the correct environment. Eg: php artisan migrate --env=production (or whatever environment).
3 years ago
No, what you are looking for would be called a parent selector. CSS has none; they have been proposed multiple times but I know of no existing or forthcoming standard including them. You are correct that you would need to use something like jQuery or use additional class annotations to achieve the effect you want.
3 years ago
Instead of using opacity, set a background-color with rgba, where 'a' is the level of transparency.

So instead of:
***
background-color: rgb(0,0,255); opacity: 0.5;
***
use
***
background-color: rgba(0,0,255,0.5);
***
3 years ago
***
3 years ago
Float one or both inner divs.

Floating one div:
***
#wrapper {
width: 500px;
border: 1px solid black;
overflow: hidden; /* will contain if #first is longer than #second */
}
#first {
width: 300px;
float:left; /* add this */
border: 1px solid red;
}
#second {
border: 1px solid green;
overflow: hidden; /* if you don't want #second to wrap below #first */
}
***
or if you float both, you'll need to encourage the wrapper div to contain both the floated children, or it will think it's empty and not put the border around them

Floating both divs:
***
#wrapper {
width: 500px;
border: 1px solid black;
overflow: hidden; /* add this to contain floated children */
}
#first {
width: 300px;
float:left; /* add this */
border: 1px solid red;
}
#second {
border: 1px solid green;
float: left; /* add this */
}
***
3 years ago
Fork the repository to your account.
Clone it locally on your machine
Create a gh-pages branch (if one already exists, remove it and create a new one based off master).
Push the branch back to GitHub.
3 years ago
You need to force a clear:both before the #main_content div is closed. I would probably move the
; into the #main_content div and set the CSS to be:

.clear { clear: both; }
Update: This question still gets a fair amount of traffic, so I wanted to update the answer with a modern alternative using a new layout mode in CSS3 called Flexible boxes or Flexbox:
***
body {
margin: 0;
}

.flex-container {
display: flex;
flex-direction: column;
min-height: 100vh;
}

header {
background-color: #3F51B5;
color: #fff;
}

section.content {
flex: 1;
}

footer {
background-color: #FFC107;
color: #333;
}



Header





Content




Footer




***
3 years ago
With word-break, a very long word starts at the point it should start and it is being broken as long as required
***
[X] I am a text that 0123
4567890123456789012345678
90123456789 want to live
inside this narrow paragr
aph.
***
However, with word-wrap, a very long word WILL NOT start at the point it should start. it wrap to next line and then being broken as long as required
***
[X] I am a text that
012345678901234567890123
4567890123456789 want to
live inside this narrow
paragraph.
***
3 years ago