Difference Between fgets and fread in PHP

AmitDiwan
Updated on 07-Apr-2020 13:02:16

2K+ Views

The ‘fgets’ function reads a line and stops when it encounters a newline −The above code opens a text file named ‘test’ in the read mode and reads the contents of the file until a newline character is encountered beginning from the starting byte. The file is then closed.The ‘fread’ function reads raw data and stops after a specific number of bytes or default bytes. This doesn’t depend on whether a newline was encountered or not −The above code opens a text file named ‘test’ in the read mode and reads 10 bytes after the starting byte. The file is ... Read More

Read Single File Inside a ZIP Archive with PHP

AmitDiwan
Updated on 07-Apr-2020 13:00:34

983 Views

To read a single fine inside z zip archive, the code is as follows −$handle = fopen('zip://test.zip#test.txt', 'r'); $result = ''; while (!feof($handle)) {    $result .= fread($handle, 8192); } fclose($handle); echo $result;The output will be the contents of the zip file.

PHP CodeSniffer vs PHP Mess Detector vs PHP Depend

AmitDiwan
Updated on 07-Apr-2020 12:59:01

182 Views

pdependThe function pdepend is used to generate a large set of software metrics from a given code base. The generated values can be used to measure the quality of a software project. They help in identifying the parts of an application where refactoring is required.phpmdThe phpmd scans the PHP source code and searches for potential problems that could be possible bugs, not-so-optimal code, or overcomplicated expressions.phpcsThe phpcs function tokenises the PHP, JavaScript and CSS files and figures out issues/violations in a set of pre-defined coding standards. It ensures that the code remains consistent and neat. It also helps in preventing ... Read More

PHP String Comparison: 0 vs String

AmitDiwan
Updated on 07-Apr-2020 12:56:04

214 Views

The syntax ‘$string{0} ‘ has been deprecated beginning from PHP version 6. Hence, it is strongly suggested to use $string[0].In short, accessing characters using the flower braces {} has been deprecated. Hence the square brackets should be used [] −Example Live Demo$string = 'medium'; echo $string{0}; echo $string[0];OutputThis will produce the following output −mm

Sort Output in PowerShell

Chirag Nagrekar
Updated on 07-Apr-2020 12:25:24

11K+ Views

To sort the output in the PowerShell you need to use Sort-Object Pipeline cmdlet. In the below example, we will retrieve the output from the Get-Process command and we will sort the, according to memory and CPU usage.ExampleGet-Process | Sort-Object WorkingSet | Select -First 10OutputHandles  NPM(K)    PM(K)      WS(K)     CPU(s)     Id  SI ProcessName -------  ------    -----      -----     ------     --  -- -----------       0       0       60          8                 0 ... Read More

What are Automatic Modules in Java 9

raja
Updated on 07-Apr-2020 12:22:23

395 Views

An automatic module is a jar that we put on the modulepath. There is a number of pre-existing libraries that can be used in our applications, and many of these are not yet modularized. To facilitate migration, we can add any library’s jar file to an application’s module path, then use packages in that jar file. It can implicitly become an automatic module and can be specified in the module declaration’s requires directive. The jar’s filename becomes its module name that must be a valid Java identifier that can be used in "requires" directive.An automatic module:Implicitly exports all package types, so ... Read More

Use Measure-Object in PowerShell

Chirag Nagrekar
Updated on 07-Apr-2020 12:21:33

2K+ Views

Measure-Object in PowerShell is used to measure the property of the command. There are various measurement parameters are available. For example, Average, Count, sum, maximum, minimum and more.ExampleGet-Process | Measure-ObjectOutputPS C:\WINDOWS\system32> Get-Process | Measure-Object Count       : 278 Average     : Sum         : Maximum     : Minimum     : Property    :Here, in the above output, there are total 278 processes are running. If you want to check the maximum memory usage then you can use WorkingSet property with − Maximum Parameter.Get-Process | Measure-Object -Property WorkingSet -MaximumOutputPS C:\WINDOWS\system32> Get-Process | Measure-Object ... Read More

Encrypting Passwords in PHP

AmitDiwan
Updated on 07-Apr-2020 12:10:49

321 Views

Due to the fact that Blowfish has vulnerabilities before PHP version 5.3.7, it would be suggested to use SHA-256 or SHA-512 instead. Both of them have a similar salt format similar to that of Blowfish (use a prefix of $5$ for SHA-256 and $6$ for SHA-512). In addition to this, it also contains an optional rounds parameter to force multiple hashing.The salt on its own is a little shorter at only 16 characters but unlike Blowfish, it allows more than just alphanumeric characters.Example Live Demoecho 'SHA-256 (no rounds): ' . crypt('password-to-encrypt', '$5$YourSaltyStringz$'); echo 'SHA-512 (with rounds): ' . crypt('password-to-encrypt', '$6$rounds=1000$YourSaltyStringz$');OutputThis will ... Read More

Check PowerShell Version Installed on Local and Remote Systems

Chirag Nagrekar
Updated on 07-Apr-2020 11:58:36

2K+ Views

To check the PowerShell version installed in your system, you can use either $PSVersionTable or $host command.Check if $host command available in remote servers.Open the PowerShell console in the system and run the command $PSVersionTable.$PSVersionTableOutputPS C:\WINDOWS\system32> $PSVersionTable Name                           Value ----                             ----- PSVersion                        5.1.18362.628 PSEdition                        Desktop PSCompatibleVersions       ... Read More

Checking Memory Limit in PHP

AmitDiwan
Updated on 07-Apr-2020 11:58:33

1K+ Views

The ‘memory_limit’ is the maximum amount of server memory that a single PHP script is allowed to use. The value needs to be converted before comparing the threshold of memory.For example − 64M is converted to 64 * 1024 * 1024. After this, the comparison is done and the result is printed out.

Advertisements