Hosting de Calidad
  • Inicio
  • Precios y servicios
  • F.a.q y ayudas
  • Realizar pedido
  • Webs alojadas
  • Quienes somos
  • Foro HyD
  • Contacto

    Zona Dominios

    Entrar
    registro de dominios


    Zona Hosting

    Entrar
    alojamiento web


    5 Métodos de Pago
    Tarjeta de crédito
    Domiciliación
    Transferencia
    Soporte Epagado
    Soporte Paypal

    Liberalización .es

    Ver mas
    dominios .es


  •  
     
     
    assert

    assert

    (PHP 4 )

    assert __ Checks if assertion is FALSE

    Description

    int assert ( mixed assertion)

    assert() will check the given assertion and take appropriate action if its result is FALSE_

    If the assertion is given as a string it will be evaluated as PHP code by assert()_ The advantages of a string assertion are less overhead when assertion checking is off and messages containing the assertion expression when an assertion fails_ This means that if you pass a boolean condition as assertion this condition will not show up as parameter to the assertion function which you may have defined with the assert_options() function, the condition is converted to a string before calling that handler function, and the boolean FALSE is converted as the empty string_

    Assertions should be used as a debugging feature only_ You may use them for sanity_checks that test for conditions that should always be TRUE and that indicate some programming errors if not or to check for the presence of certain features like extension functions or certain system limits and features_

    Assertions should not be used for normal runtime operations like input parameter checks_ As a rule of thumb your code should always be able to work correctly if assertion checking is not activated_

    The behavior of assert() may be configured by assert_options() or by _ini_settings described in that functions manual page_

    The assert_options() function and/or ASSERT_CALLBACK configuration directive allow a callback function to be set to handle failed assertions_

    assert() callbacks are particularly useful for building automated test suites because they allow you to easily capture the code passed to the assertion, along with information on where the assertion was made_ While this information can be captured via other methods, using assertions makes it much faster and easier!

    The callback function should accept three arguments_ The first argument will contain the file the assertion failed in_ The second argument will contain the line the assertion failed on and the third argument will contain the expression that failed (if any _ literal values such as 1 or "two" will not be passed via this argument)

    Ejemplo 1_ Handle a failed assertion with a custom handler

    <?php
    // Active assert and make it quiet
    assert_options (ASSERT_ACTIVE, 1);
    assert_options (ASSERT_WARNING, 0);
    assert_options (ASSERT_QUIET_EVAL, 1);
    
    // Create a handler function
    function my_assert_handler ($file, $line, $code) {
        echo "<hr>Assertion Failed:
            File '$file'<br>
            Line '$line'<br>
            Code '$code'<br><hr>";
    }
    
    // Set up the callback
    assert_options (ASSERT_CALLBACK, 'my_assert_handler');
    
    // Make an assertion that should fail
    assert ('mysql_query ("")');
    ?>

     
       



    registro de dominios | alojamiento web | hosting por publicidad

       

     

    Manual de linux Manual de apache Manual de php Manual de mysql Manual de SQL Manual del Plesk Como funciona Paypal Manual de html