Reading about the C++ language I have seen that some developers talk about C++17 and it is not clear to me if it is the same as C++ or if it is another language.
What is C++17?
Reading about the C++ language I have seen that some developers talk about C++17 and it is not clear to me if it is the same as C++ or if it is another language.
What is C++17?
I have the following code:
var obj = {};
if (obj != null) {
//execute
}
The problem is that obj
it is not null.
How can I know if an object is empty so that it enters a condition or not?
It's a question I've had for a long time.
I've wanted to ask this for a long time, and I'm posting the question in the hope that it won't be closed because it's based on opinions... If that happens, it could be an answer for me : No.
The question I have is whether we can talk about Object Oriented Programming (OOP) in PHP in the strict sense of the word or if, on the contrary, only some OOP principles can be applied in PHP.
I expect answers, if any, based on documentation and evidence.
When I see the examples of the PHP Manual in this regard, or the so-called magic methods , it gives the impression that basic OOP concepts are violated, as is the case of creating setters
public access.
The specific question is the following: Can we say that with PHP you can do OOP in the strict sense of the word? Why?
I have recently seen in the question How to create a global function that contains the id of the urls? that in one of your answers you mention that global variables are generally bad practice.
For reference there is this question: Why is it considered bad practice to use global variables? there is a lot of confusing documentation, some badly criticized global functions, unless I'm confused on the subject and my global variables are not global.
It is said in one of the answers that global variables create hidden dependencies, when it comes to large applications, mentioning that you don't even know/remember/are not clear about the objects you have and their relationships.
Global variables within functions are a great utility, I consider them that way, when working together with PHP
& HTML
.
In this example I don't see how it can be a bad practice, unless there is some security vulnerability in them.
$connect = new mysqli('127.0.0.1', 'tu_usuario', 'tu_contraseña', 'sakila');
function user(){...
global $connect; //conexión a la base de datos
// Código de la consulta
}
Function result in HTML
<div><?php user();?></div>
Could you explain to me what a bad practice would be?
Which variables are determined as a global variable?
PHP reserved words global $conexion;
are involved in the theme.
Note: There is a question why it is considered a bad practice, perhaps it is linked to the same topic, but the question is very different from each other, there is a way to use it but no examples for beginners in programming, a lot of theory without practice would be confusing, In short, the answer is about seeing more of the bad side of a solution, it is for me something very confusing between so many lines, even though I have programming experience.
With JavaScript/jQuery I can create events for when the mouse enters or leaves an element using mouseenter
and mouseleave
. For example:
var img = document.querySelector("img");
img.addEventListener("mouseenter", function() {
console.log("Estoy sobre la imagen");
});
img.addEventListener("mouseleave", function() {
console.log("Ya no estoy sobre la imagen");
});
<img src="http://placehold.it/200" />
This will cause actions to be executed (display messages on the console) when the mouse enters or leaves the image. Now my question is: is there an event that instead of being fired when the mouse enters the image, is fired when the mouse is in the proximity of the image?
For example, if I have an image (although it could potentially be anything like a div
or a thead
) next to some text, and the mouse comes within 30px of the image's border, an action is executed in JavaScript. This graphic shows more or less what I want - something should happen if the mouse enters the area around the image (highlighted in red for example only, it's an "imaginary" area):
If it doesn't exist, how could that event be simulated with JavaScript or jQuery?