- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 1046 Articles for PHP
![Malhar Lathkar](https://www.tutorialspoint.com/assets/profiles/211197/profile/60_4699-1591856239.jpg)
190 Views
IntroductionAssertionError class is a subclass of Error class. This type of error is thrown when assert() returns FALSEassert() checks if given assertion is true or false, and throws AssertionError if it is false. The assert() function is defined as follows −Syntaxfor PHP 5 and PHP 7 assert ( mixed $assertion [, string $description ] ) : bool PHP 7 only assert ( mixed $assertion [, Throwable $exception ] ) : boolParametersSr.NoParameter & Description1assertionstring or boolean expression2descriptionfailure mssage3exception (for PHP 7 only)throwable objectSince PHP 7.0, assert() is now a language construct and not a function. assertion parameter can now be an expression ... Read More
![Malhar Lathkar](https://www.tutorialspoint.com/assets/profiles/211197/profile/60_4699-1591856239.jpg)
165 Views
IntroductionIn PHP 7.3 onwards, CompileError exception has been added. This class inherits Error class. Some error conditions that previously resulted in fatal error, now throw a CompileError. This affects compilation errors that are likely to be thrown by token_get_all() function.The token_get_all() function uses Zend lexical scanner to parse a given string into PHP language tokens.Syntaxtoken_get_all ( string $source [, int $flags = 0 ] ) : arrayParametersSr.NoParameter & Description1sourcePHP source to parse2flagTOKEN_PARSE - Recognises the ability to use reserved words in specific contexts.The function should be used in TOKEN_PARSE mode to be able to raise CompileError.Read More
![Malhar Lathkar](https://www.tutorialspoint.com/assets/profiles/211197/profile/60_4699-1591856239.jpg)
2K+ Views
IntroductionDivisionByZeroError class is a subclass of ArithmeticError class. This type of error occurs when division operation involves value of denominator as zero. This can also occur when a modulo operator (%) has 0 as second operator, and intdiv() function having second argument as 0.DivisionByZeroError ExampleIn first example, we try to perform modulo division of 10 and 0 using % operator to induce DivisionByZeroError.Example Live DemoOutputThis will produce following result −Modulo by zeroIf call to intdiv() function with 0 as second argument also raises DivisionByZeroError as followsExample Live DemoOutputThis will produce following result −Division by zeroDivision operator (/) having 0 as denominator, however fails to raise error, ... Read More
![Malhar Lathkar](https://www.tutorialspoint.com/assets/profiles/211197/profile/60_4699-1591856239.jpg)
306 Views
IntroductionPHP's Exception class implements the Throwable interface. ErrorException class extends the Exception class. ErrorException is meant to be explicitly thrown when you want to catch and handle errors that would otherwise be ignored, such as Notices or Warnings.PHP core consists of following predefined error constantsValueConstantDescription1E_ERRORFatal run-time errors.2E_WARNINGRun-time warnings (non-fatal errors).4E_PARSECompile-time parse errors.8E_NOTICERun-time notices.16E_CORE_ERRORFatal errors that occur during PHP's initial startup.32E_CORE_WARNINGWarnings (non-fatal errors) that occur during PHP's initial startup.64E_COMPILE_ERRORFatal compile-time errors.128E_COMPILE_WARNINGCompile-time warnings (non-fatal errors).256E_USER_ERRORUser-generated error message.512E_USER_WARNINGUser-generated warning message.1024E_USER_NOTICEUser-generated notice message.2048E_STRICTIf Enabled PHP suggests changes to your code to ensure interoperability and forward compatibility of your code.4096E_RECOVERABLE_ERRORCatchable fatal error.8192E_DEPRECATEDRun-time notices.16384E_USER_DEPRECATEDUser-generated warning message.32767E_ALLAll ... Read More
![Malhar Lathkar](https://www.tutorialspoint.com/assets/profiles/211197/profile/60_4699-1591856239.jpg)
227 Views
IntroductionParseError class extends CompileError class. (Earlier it used to be subclass of Error class). This type of error is thrown while a PHP code inside a string that is given to eval() function as argument.The eval() function evaluates given string as PHP code.Syntaxeval ( string $code ) : mixedParametersSr.NoParameter & Description1codevalid PHP code to be evaluatedCode to be evaluated must not be embedded in PHP opening and closing tags and must be terminated by semicolon. Valide code retuns NULL whereas error in code throws ParseErrorFollowing example throws ParseError and is handled by catch blockExample Live DemoOutputThis will produce following result −Parse Error:syntax ... Read More
![Malhar Lathkar](https://www.tutorialspoint.com/assets/profiles/211197/profile/60_4699-1591856239.jpg)
189 Views
IntroductionTypeError class extends Error class. This error is raised when actual and formal argument types don't match, return type doesn't match the decalred returned type or invalid arguments passed to any built-in functionNote that strict_types should be set to true with declare() function at the top of script −In this example, types of formal and actual argument variables don't match, resulting in TypeError.Example Live DemoThis will produce following result −OutputArgument 1 passed to add() must be of the type integer, string given, called in C:\xampp\php\test.php on line 9In following example, user defined function is supposed to return integer data, instead it is returning ... Read More
![Malhar Lathkar](https://www.tutorialspoint.com/assets/profiles/211197/profile/60_4699-1591856239.jpg)
316 Views
IntroductionPHP's internal Error types are represented by classes that are inherited from Error class. The Error class implements Throwable interface. Properties and methods of Error class are as follows −propertiesmessage − The error messagecode − The error codefile − The filename where the error happenedline − The line where the error happenedmethods__construct() − Construct the error objectgetMessage() − Gets the error messagegetPrevious() − Returns previous ThrowablegetCode() − Gets the error codegetFile() − Gets the file in which the error occurredgetLine() − Gets the line in which the error occurredgetTrace() − Gets the stack tracegetTraceAsString() − Gets the stack trace as ... Read More
![Malhar Lathkar](https://www.tutorialspoint.com/assets/profiles/211197/profile/60_4699-1591856239.jpg)
1K+ Views
IntroductionList of Context options for ssl:// and tls:// transports.peer_namePeer name to be used. If this value is not set, then the name is guessed based on the hostname used when opening the stream.verify_peerRequire verification of SSL certificate used. Defaults to TRUE.verify_peer_nameRequire verification of peer name. Defaults to TRUE.allow_self_signedAllow self-signed certificates. Requires verify_peer. Defaults to FALSEcafileLocation of Certificate Authority file on local filesystem to be used to authenticate identity of remote peer.capathmust be a correctly hashed certificate directory.local_certPath to local certificate file on filesystem.local_pkPath to local private key file on filesystem in case of separate files for certificate and private key.passphrasePassphrase with which ... Read More
![Malhar Lathkar](https://www.tutorialspoint.com/assets/profiles/211197/profile/60_4699-1591856239.jpg)
275 Views
IntroductionAccess to filesystem and various other stream wrappers can be customized by various context options and parameters configures by stream_context_create() and stream_context_set_option() functions.Following list shows various socket context options are available for all wrappers that work over sockets, like tcp, http and ftp.bindtospecifies the IP address (either IPv4 or IPv6) and/or the port number used to access the network. (ip:port for IPv4 [ip]:port for IPv6).backloglimits number of outstanding connections in socket's listen queue.ipv6_v6onlyOverrides the OS default regarding mapping IPv4 into IPv6.so_reuseportAllows multiple bindings to a same ip:port pair.so_broadcastEnables sending and receiving data to/from broadcast addresses.tcp_nodelayIf TRUE, sets SOL_TCP, NO_DELAY=1 appropriately, disabling ... Read More