Jump to content

requinix

Administrators
  • Posts

    15,064
  • Joined

  • Last visited

  • Days Won

    414

Posts posted by requinix

  1. The way you describe this makes it sound like you're doing something more complicated than what it should be...
    With a proper server, you can use a normal <link> to your CSS file and never need to clear a cache - if you do then that means it's not configured properly.

    The question to answer first is whether your browser is receiving the correct <link>, and if so why it isn't loading the CSS. My guess would be the file path, as you need to remember that $stylecss is relative to the webpage URL and not to the config.php file path.

  2. If you want a distinction between $this (use the instance) and self (use the class statically) then create an enum with cases for instance vs. static, and take that enum as the argument to your attribute.

    But ultimately, the caring about the instance/class needs to happen by whatever code is reading the attribute. As in, you must necessarily already have code that says "for this particular class, find me the attributes" - so reuse that information.

  3. Remember the part where I said

    On 10/16/2023 at 2:12 AM, requinix said:
      ["result"]=>
      array(6) {

    It has a "result" property, which is an array.

    And remember the part where I posted

    On 10/16/2023 at 2:12 AM, requinix said:
    $results = array_reduce($object->results, function($array, $result) {

    Take the time to understand what I was describing about how to read the var_dump output, then look at that one line of code I posted to see if it makes sense according to what I described. It should not make sense, and you should be able to spot a small error.

    I'm trying to get you to learn here, instead of just accepting what a person on the internet says and copy/pasting their code. You can't be a chef by copying someone else, and you can't be a programmer by copying someone else.

  4. 1 hour ago, ohno said:

    I then have this code lower down in my script :

    But what's everything in between?

    Or rather, what's the whole script? Because there's something important here that isn't shown in what you've posted - if statements, function calls, reused variables...

    Also, partly for good measure and partly because there's a rather high likelihood that doing so will help you discover the problem: have you verified that your error reporting/logging settings are appropriate, and then checked for error messages?

  5. 39 minutes ago, rick645 said:

    ok maybe it's right, in my case, to use inheritance

    Probably.

    Inheritance represents an "is a" relationship. Would it be accurate to say that your custom exception class "is an" InvalidArgumentException? If I had code that caught InvalidArgumentException, should that code also be able to catch your exception?
    Composition represents a "has a" relationship - or "needs a", or something else similar to that. Would it be accurate to say that your exception class "has an" InvalidArgumentException? Is your class a distinct form of exception separate, but not entirely unrelated to, an InvalidArgumentException?

    The answer seems like it would be the first one, however the $otherDetails is suspicious and suggests something more than an invalid argument, thus perhaps composition is more appropriate, however the fact that you chose to make it anonymous means it will be impossible to catch or type guard for that particular class in the first place, which makes composition almost useless.

    In other words, your example doesn't make sense. If you want a special exception class then it should be a full named class. If you want special exception data then it needs to be a full named class.

    And that is the real code smell.

  6. 51 minutes ago, rick645 said:

    Many say they avoid inheritance and to encourage composition.

    But do you actually understand why they say that? Because they are not saying that inheritance is bad.

    So tell me: in this situation you find yourself in, why do you feel that composition is better than inheritance?

  7. object(stdClass)#12 (4) {

    The value you dumped is an object.

      ["result"]=>
      array(6) {

    It has a "result" property, which is an array.

        [...]=>
        object(stdClass)#11 (2) {

    Somewhere in that array (you should probably not rely on it being in a particular place) is an object.

          ["code"]=>
          string(8) "switch_1"

    It has a "code" property, which is a string with the value "switch_1".

          ["value"]=>
          bool(true)

    That same object has a "value" property, which is the boolean value true.

    This is an awkward structure to work with. What if you wanted other things besides the switch_1? Wouldn't it be nice if you had a single object/array that had everything at once?

    Try this:

    // assuming $object was the variable you dumped,
    $results = array_reduce($object->results, function($array, $result) {
        $array[$result->code] = $result->value;
        return $array;
    }, []);

    Then try dumping out $results and see if the data is easier to use in that form.

  8. .obj :hover > div :hover

    That will target an .obj with a descendant-element you are hovering over which contains a DIV with another descendant-element you are hovering over. In other words, your HTML has to be something like

    <A class="obj">
      <B>
        <div>
          <C>
            <!-- hovering here -->
          </C>
        </div>
      </B>
    </A>

    I doubt that's what you want.

    :hover isn't cinnamon, so you can't sprinkle it over miscellaneous elements and expect them to taste better.

    If you want the animation to play while hovering over the DIV then apply :hover directly to it alone - while also remembering that whitespace in CSS is occasionally significant.

    .obj > div:hover

     

  9. Most of the time, when you find an oddity like this that can't be explained any other way, the answer is going to be a JIT thing: PCRE isn't supposed to, but occasionally does behave in slightly different ways when JIT is on or off.

    ini_set("pcre.jit", 0);
    preg_match('/([^\.]|^)\s*a/', "a", $matches);

    But turning off JIT is not the best answer. Instead, do what kicken did and tweak the expression so it works.

    Anyway, that expression really should work even with JIT enabled, so feel free to file a bug report against PCRE2 about it.
    https://github.com/PCRE2Project/pcre2/issues

  10. 3 hours ago, phppup said:

    When opened on my Android phone with a Chrome browser, I received an error Y0ZkNV.

    That's not an error. That's a link. Specifically, a link to https://goo.gl/Y0ZkNV.

    Pay more attention.

    3 hours ago, phppup said:

    Is there a way to resolve this without changing my hosting to an HTTPS platform?

    Not if you want to do this from Javascript. But you should change to HTTPS regardless.

    To do it from PHP, if you can accept that you will not get an accurate location, you look up the remote IP address in some geolocation database - MaxMind's, for instance.

  11. There are two approaches that aren't unreasonable:

    1. Make your thing render as an image, and embed the image into the description (assuming it supports HTML). Then whoever sees the description will see the image. Not great for SEO or visually-impaired users.
    2. Set up a cronjob that runs a script every X minutes (whatever makes sense to you). This script calculates what it needs, then goes into the database and manipulates the forum's description text.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.